wstringstream doesn't output correct data

I was writing a program when I ran into a problem. I was trying to use wstringstream to get data from wstring. All went fine until few last variables didn't get correct values, in fact they didn't get anything from the stream. I wrote a small application to show what happens:
http://pastie.org/2799401
Image showing that values aren't correct:
http://img683.imageshack.us/img683/4817/streamproblem.png

Any Idea why this happens, possible 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
25
26
27
   strs >> maxhealth;         // 100
   strs >> health;            // 100
   strs >> maxmana;           // 100
   strs >> mana;              // 100
   strs >> maxfatigue;        // 100

   strs >> fatigue;           // 5
   strs >> str;               // 5
   strs >> agl;               // 5
   strs >> lck;               // 5
   strs >> per;               // 5
   strs >> wpow;              // 5
   strs >> inte;              // 5

   strs >> end;               // 1
   strs >> TempC;             // 1

   strs >> TempRa;            // "Enemy1" - ???
   // Error, stops reading from stream

   strs >> name;              // derfault: L" "
   strs >> chunkx;            // derfault: 1
   strs >> chunky;            // derfault: 1
   strs >> id;                // derfault: 1
   strs >> exists;            // derfault: 1
   strs >> X;                 // derfault: 1
   strs >> Y;                 // derfault: 1 
Last edited on
I just realized the problem is actually in reading the file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	int npccount;
	savefile >> npccount;
	int junk;
/// I need to get to next line here, it seems that I did it by reading first value from that line ////
	savefile >> junk;
//	QuickMessage(hWnd,junk); /// confirms that it read the first 100
	if (npccount > 0){
		for (int i=0; i < npccount; i++){
			char filecont[400];
			string fromfile="";
			savefile.getline(filecont,400);
			fromfile=filecont;
//			QuickMessage(hWnd,fromfile);
			int empt=npc::GetEmptySlot();
			npcarray[empt]=npc(fromfile);
		}
	}

How do I get to next line without taking anything from it, or should I just make it so that it is written to end of previous line- will though cause problems later?
Topic archived. No new replies allowed.