Hi folks,
I've come across a peculiar behavior of the program written below:
Upon compiling this program using MinGW (on Win XP), the compilation goes fine without errors but the program hangs when it is run.Code:#include<stdio.h> #include<stdlib.h> void removevowels(char* sen); int main() { char *sen = "Hello, Good Morning!!"; printf("String before function call: %s\n", sen); removevowels(sen); printf("String after function call: %s\n", sen); return 0; } void removevowels(char* sen) { char *p, *q; p = q = sen; while(*p != '\0'){ printf("sen = %x\n", sen); printf("p = %x\n", p); printf("q = %x\n", q); printf("%s\n\n", p); switch(*p){ case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': p++; break; default: *q = *p; p++; q++; break; } } *q = '\0'; }
The same is not happening if I compile and run using Borland C Compiler (on Win XP).
I added a few printf statements and found that it hangs at the switch statement.
Please share your thoughts on this.
Regards
maverix



LinkBack URL
About LinkBacks



