Thread: Use of while

  1. #1
    Unregistered
    Guest

    Use of while

    Is this a valid use of the while() command?

    char *p1;
    char name[100];
    .
    .
    .
    while((p1=strchr(name,','))!=NULL) memmove(p1,p1+1,strlen(p1));

    My compiler compiles fine, but when I execute it, the brackettes of other statements get all screwed up and the program flow/logic is fragged. Doing the following works as expected:

    while((p1=strchr(name,','))!=NULL) {
    memmove(p1,p1+1,strlen(p1));
    }

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Both loops are valid and correct. Could you show some more of your code? Perferably something we can compile and play with?

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed