Erstellen Sie ein string-array mit Zeichen in C

Wenn ich dies tun

char *paths[10];
paths[0] = "123456";

printf(1,"%s\n",paths[0]);
printf(1,"%c\n",paths[0][2]);

Ausgabe:

123456
3

Aber wenn ich Sie dies tun

char *paths[10];
paths[0][0]='1';
paths[0][1]='2';
paths[0][2]='3';
paths[0][3]='4';
paths[0][4]='5';
paths[0][5]='6';
printf(1,"%s\n",paths[0]);
printf(1,"%c\n",paths[0][2]);

Ausgabe:

(null)
3

Warum es null, in diesem Fall?
So erstellen Sie ein string-array mit Zeichen, die in C? Ich bin ein bisschen neu in C und Gefühl einige Schwierigkeiten, das Programm in C

InformationsquelleAutor SMUsamaShah | 2011-09-28

Schreibe einen Kommentar