Thread: Use of while

  1. #1

    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) {

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

    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed
Website Security Test