Reading a mix of strings, ints and doubles from a file in C++ -


i have .txt file looking this:

1 string other string 3 10,5 20 20 

i need read these values different type of variables. far ints , doubles reading file seems working comes strings fun begins.
seems strings read try output them whole console crash.

edit: "crash" mean "not responding" type of message appears. , code use basically:

ifstream file; file.open ("c:\path\file.txt"); file >> int1;  getline(file, string1); getline(file, string2); file >> int2; file >> double1; file >> double2; file >> double3; // ....  file.close(); 

edit 2: somehow instead of 1 value of int1 -858993460.

i getting confused...

edit 3: vales being set not values written in file. first int , first srting fine second string red 0 , doubles red

-92559631349317830000000000000000000000000000000000000000000000 

since there more values in file , accept pattern type ran cycle them problem after first read values not red again.

file.open ("c:\path\file.txt");

\ escape character

fix

file.open ("c:\\path\\file.txt");


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -