\
#include < stdio.h> void main(void) { printf("%s, %p, %c\n", "We", "love", *"snow"); }
char m1[] = "We love snow"; char m1[] = {'W', 'e', ' ', 'l', 'o', 'v', 'e', ' ', 's', 'n', 'o', 'w', '\0'}; m1 == &m1[0], *m1 == 'W', *(m1 + 1) == m1[1] == 'e' char *m2 = "We love snow";
char *m3[3] = {"We", "love", "snow"}; (ragged array) char m4[3][4] = {"We", "love", "snow"}; (rectangular array)
#include < stdio.h> void main(void) { static char * mesg = "Don't be a fool!"; static char * copy; copy = mesg; printf("%s\n", copy); printf("mesg= %s &mesg= %p; value= %p\n", mesg, &mesg, mesg"); printf("copy= %s &copy= %p; value= %p\n", copy, &copy, copy"); }
static char *name; scanf("%s", name); /* wrong */
ptr= gets(name); while(gets(name != NULL))
puts(name[3]); puts(ptr + 3);
/* Listing 11.22 -- string-pointer-sorting function */ vodi ststr(char *strings[], int num) { char *temp; int top, seek; for (top = 0; tom < num - 1; top++) for (seek = top + 1; seek < num; seek++) if (strcmp(strings[top], strings[seek]) > 0) { temp = strings[top]; strings[top] = strings[seek]; strings[seek] = temp; } }
#include <stdio.h> void main(int argc, char *argv[]) { int i; for (i = 0; i < argc; i++) printf("%d: %s\n", argv[i]); printf("\n"); }
#include <stdio.h> #include <console.h> void main(int argc, char *argv[]) { int i; argc = ccommand(&argv); for (i = 0; i < argc; i++) printf("%d: %s\n", argv[i]); printf("\n"); }