Home > database >  notes
notes

Time:09-27

Array (1, use char ch initialize a string array []="hello world" the scanf (" % s ", ch); Printf (" % s ", ch); Gets 2, string handling functions (ch) * * * * * * * * * * * * * * * * * * * * * * * * * * * a pointer variable pointing to the char * string STR="hello"//use string constants of character pointer initialized STR=STR + 2; STR="world" is equivalent to char * STR; STR="hello" char ch []="hello" char ch [10]; Ch="hello" error char *//STR=ch; String is stored in the form of an array in c memory char * mystrcat (char ch1 [], char * ch2) {int I, j; For (I=0;; I++) {if (ch1 [I]=='\ 0') break; } the for (j=0;; J++) {if (ch2) [j]=='\ 0') break; } the for (y=0, x=I; Y<=j; X++ y++) {ch1 [x]=ch2 [y]; } return ch1; } char * mystrcat (char * ch1 and ch2 char *) {int I, j; For (I=0;; I++) {if (* (ch1 + I)=='\ 0') break; } the for (j=0;; J++) {if (* (ch2 + j)=='\ 0') break; } the for (y=0, x=I; Y<=j; X++ y++) {* (ch1 + x)=* (ch2 + y); } return ch1; } case, char * string concatenation function mystrcat3 (char * ch1 and ch2 char *) {char * p=ch1; While (* ch1!='\ 0') ch1 + +; While (* ch2! Ch1=='\ 0') {* * ch2; Ch1 + +; Ch2 + +; Ch1} *='\ 0'; Return the p; } # define A 5 # define B 6 # define A + C Bint x=====2 * C & gt; X=2 * A + B==x=2 * 5 + 6