Trouble with saving String into .txt

I am writing a program that read entered string and its length from input.

I have to save string and length into .txt document.

I am having issues with saving it using fstream class.

So far I have this code.
// There is line 17 error: 'std::string' has no member named 'lenght'|
I cant find the solution ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
      int main()
     {

      string x ;
      ofstream niz;
      niz.open ("C:Niz.txt");
      cout <<"Unesite znakovni niz: " << endl;
      getline (cin, x) ;
      cout << endl << "You entered: " << x << " Lenght is: "<< x.length() <<endl;

      niz << x << x.lenght() << endl;
      niz.close ();
      return 0;



 }
Last edited on
Check your spelling.

Oh my bad english again... Thank you
Topic archived. No new replies allowed.