Thread: Desperate

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    94

    Desperate

    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.....

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Someone pls help me solve this....

    there has to be some way I can do this while loop

    while (str[i] != ' \')
    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:

    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");
    }
    Alternately I could have not use the 'str[i++]' and incremented i some place in the loop.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    94
    It doesn't work I keep getting : unterminated character constant
    simple is always an understatement.....

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    delete
    Last edited by Barjor; 04-11-2002 at 03:50 PM.

  5. #5
    Registered User WayTooHigh's Avatar
    Join Date
    Aug 2001
    Posts
    101
    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.

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    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");
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Desperate Over Ecs!
    By cookie in forum C Programming
    Replies: 17
    Last Post: 07-16-2008, 01:25 PM
  2. Debugging Help - I'm Desperate
    By Tman in forum Game Programming
    Replies: 2
    Last Post: 02-21-2006, 01:39 PM
  3. Desperate Help needed
    By roco090 in forum C++ Programming
    Replies: 9
    Last Post: 02-18-2005, 09:43 PM
  4. I don't like doing this but i'm desperate
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 07-21-2002, 06:44 PM
  5. Desperate for help - ugly nested if
    By baseballkitten in forum C Programming
    Replies: 4
    Last Post: 11-19-2001, 03:56 PM