wrong reading.

wht I want is name and surname=burcin erek number=783389
but output name and surname=burcin number=erek
it is so funny but no solution.

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>

using namespace std;

void file_read()
     string name1;
     string numb1;
     ifstream f("file1.txt");
     cout << "name and surname=" << name1 << "\n number=" << numb1<<"\n";

void file_write()
string nam="burcin erek";
string numb="783389";

ofstream f("file1.txt");
f << nam  <<" " << numb;

int main(int argc, char *argv[])
    return EXIT_SUCCESS;

Edited 4 Years Ago by mike_2000_17: Fixed formatting

Please correct the code tags.

>> operator reads until the first whitespace character. So when you are reading the file which has "burcin eric 783389" with the following code


name1 gets burcin and numb1 gets erec.

Edited 6 Years Ago by vidit_X: n/a

it means that there is no space between burcin erek
i did like burcin.erek it works.

This question has already been answered. Start a new discussion instead.