Monday, May 24, 2010

Solving a problem for c++ Arrays?

I try using a value of a string for example string value[] to establish a condition in a loop, only it give me this error :(


"C++ forbids comparison between pointer and integer"


Can you establish a string inside a while loop and what conditions do you need?


string value[]





for ( )


while (value != '$')


{


code


}

Solving a problem for c++ Arrays?
The problem here is that





string value[]





declares an _array_ of strings. The code then tries to compare value (which is a pointer to an array of strings), to '$', which is a character (an 8-bit integer).





If you want to compare a string in the while loop, you need to compare a string to a string. For example:





while ( value[0] != "$" )





This will compare the string at index 0 of the value array, to the string "$". Note that double quotes is used to specify a string, whereas a single quote is used to specify a character.
Reply:No.
Reply:Quit = fasle;


while(true){


if(string =='fsdf')


{


//do this


}else


{


//do this


Quit = true;


}


}


if(Quit = true)


break;


}


No comments:

Post a Comment