Mar 7, 2006 #1 antonaras Programmer Joined Mar 7, 2006 Messages 2 Location GB ok simmple question how to output a datatype of type string? to be more specific #include <string> string word; char i; while(i=getc(pFile)!='>') { word += i; } //Here i want to output the value of word how can i do it pls help it must be easy for u
ok simmple question how to output a datatype of type string? to be more specific #include <string> string word; char i; while(i=getc(pFile)!='>') { word += i; } //Here i want to output the value of word how can i do it pls help it must be easy for u
Mar 7, 2006 #2 cpjust Programmer Joined Sep 23, 2003 Messages 2,132 Location US Code: cout << word << endl; Upvote 0 Downvote
Mar 7, 2006 #3 Salem Programmer Joined Apr 29, 2003 Messages 2,455 Location GB > while(i=getc(pFile)!='>') You also need to fix your precedence. What you have is Code: while(i = [b][COLOR=red]([/color][/b]getc(pFile)!= '>'[b][COLOR=red])[/color][/b] ) This basically causes i to have the value 1, until it matches a > at which point it has the value 0 and the loop exits. What you're more likely to want is Code: while( [b][COLOR=red]([/color][/b]i = getc(pFile)[b][COLOR=red])[/color][/b] != '>' ) -- Upvote 0 Downvote
> while(i=getc(pFile)!='>') You also need to fix your precedence. What you have is Code: while(i = [b][COLOR=red]([/color][/b]getc(pFile)!= '>'[b][COLOR=red])[/color][/b] ) This basically causes i to have the value 1, until it matches a > at which point it has the value 0 and the loop exits. What you're more likely to want is Code: while( [b][COLOR=red]([/color][/b]i = getc(pFile)[b][COLOR=red])[/color][/b] != '>' ) --