Liste des Groupes | Revenir à cl c |
This program segfaults at the commented line:text is pointing to "this is a test" - and that is stored in the program binary and that's why can't modify it.
#include <ctype.h>
#include <stdio.h>
void uppercase_ascii(char *s) {
while (*s) {
*s = toupper(*s); // SEGFAULT
s++;
}
}
int main() {
char* text = "this is a test";
printf("before [%s]\n", text);
uppercase_ascii(text);
printf("after [%s]\n", text);
}
Les messages affichés proviennent d'usenet.