Someone pls help me solve this....
there has to be some way I can do this while loop
while (str[i] != ' \ ')
Someone pls help me solve this....
there has to be some way I can do this while loop
while (str[i] != ' \ ')
simple is always an understatement.....
What do you mean "there has to be some way I can do this while loop". You just did. What's your problem? The only thing you're missing is incrementing 'i'. Example:Someone pls help me solve this....
there has to be some way I can do this while loop
while (str[i] != ' \')
Alternately I could have not use the 'str[i++]' and incremented i some place in the loop.Code:#include <stdio.h> int main (void) { char str[10] = "12345\789"; int i = 0; while(str[i++] != '\') printf("%c", str[i] ); return printf("\n"); }
Quzah.
Hope is the first step on the road to disappointment.
It doesn't work I keep getting : unterminated character constant
simple is always an understatement.....
delete
Last edited by Barjor; 04-11-2002 at 03:50 PM.
try adding another slash and don't forget increment i
while (str[i] != ' \\')
if you declare str, like so...
char str[10] = "12345\789";
dont forget to add the extra slash.
char str[10] = "12345\\789";
Sometimes, the farthest point from the center is the center itself.
Your life is your canvas, it's only as beautiful as you paint it.
This compiles fine on my puter VC++
Code:#include <stdio.h> int main (void) { char str[10]; int i = 0; while(str[i++] != '\\\') printf("%c", str[i] ); return printf("\n"); }