Liste des Groupes | Revenir à cl c |
On 2024-08-01, Bart <bc@freeuk.com> wrote:
>On 01/08/2024 20:39, Kaz Kylheku wrote:>
>On 2024-08-01, Mark Summerfield <mark@qtrac.eu> wrote:>
>This program segfaults at the commented line:>
>
#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";
The "this is a test" object is a literal. It is part of the
program's image.
So is the text here:
>
char text[]="this is a test";
>
But this can be changed without making the program self-modifying.
The array which is initialized by the literal is what can be
changed.
>
In this situation, the literal is just initializer syntax,
not required to be an object with an address.
Les messages affichés proviennent d'usenet.