









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










is handled as char * literal = “abc”;printf(literal);
“Gainesville^ Airport”;char location[20] = {‘G’,’a’,’i’,’n’,’e’,’s’,’v’,’,i’,’l’,’l’,’e’,’ ‘,’A’,’i’,’r’,’p’,’o’,’r’,’t’,’\0’}; ^ Like any other arrays, if length of the variable is less than 20,we’ll fill them up with \0 ^ Initialization string cannot be longer than the size of the stringdeclared ^ if you declare^ char^ location[]
=^ “Gainesville Airport”;^ and not specify its size, can you change the sizelater? No we can also declare^ char^ *****
location;^ array and pointers are closely related, but are not always interchangeable (e.g.location cannot point to somewhere else in array version) Always allocate memory before you use the dynamic pointerversion
strikes^ 12”; printf(“The^ message:
%s\n”,^ str); ^ we can put the length in the conversionspecifications ^ Another way:^ puts(str);^ ^ no conversion specifications,^ ^ always ends with new line
^ char * str1 = “abcd”;^ ^ char * str2 = (char *) malloc (5);strcpy(str2, “abcd”); char * strcat(char *s1, const char *s2);^ ^ strcpy(str1, “efg”); char * strcmp(const char * s1, const char * s2);^ ^ How to they compare? size_t strlen(const char * s)