[ Pretender @ 22.11.2003. 20:34 ] @
Jedno `malo` pitanje:

Code:

1:     #include <fstream.h>
2:     int main()
3:     {
4:        char fileName[80];
5:        char buffer[255];    // for user input
6:        cout << "File name: ";
7:        cin >> fileName;
8:
9:        ofstream fout(fileName);  // open for writing
10:       fout << "This line written directly to the file...\n";
11:       cout << "Enter text for the file: ";
12:       cin.ignore(1,'\n');  // eat the newline after the file name
13:       cin.getline(buffer,255);  // get the user's input
14:       fout << buffer << "\n";   // and write it to the file
15:       fout.close();             // close the file, ready for reopen


Citat:
The newline character left over from the user's input of the filename is eaten on line 12, and the user's input is stored into buffer on line 13.



Ne vidim gde je to ostavljen karakter \n posle unosa filename ?


Tx
[ leka @ 15.12.2003. 13:48 ] @
getline() bi trebalo da u bafer strpa i '\n' ...