Basic knowledge of characters and strings
/* ===================================================== ============================================================ Name: testChar. c Author: lf Version: Copyright: Your copyright notice Description: basic knowledge of characters and strings ============================================= ========================================================== = */# include <stdio. h> # include <stdlib. h> int main (void) {testChar (); testArray (); return EXIT_SUCCESS ;} /*** use characters to represent the result of 'A' + 1 *, that is, printf ("% c \ n", 'A' + 1 ); output B *. The result of 'A' + 1 is represented by an integer * ("% d \ n", 'A' + 1 ); output 98 * These are all obtained by the ASCII code. * Some escape characters are worth noting. For example, '\ 0' indicates the terminator NUL In the ASCII code */void testChar () {printf ("% c \ n ", 'A' + 1); printf ("% d \ n", 'A' + 1);}/*** the string can be considered as an array, each element in the array is struct. * So: * char c = "hello" [0]; * printf ("% c \ n", c ); * The character h can be printed ** because "strings can be considered as an array, each element in the array is character-type "* so you can use a string to initialize a character array **/void testArray () {char c =" hello "[0]; printf ("% c \ n", c); char charArray [] = "world"; // equivalent to // char charArray [] = {'w ', 'o', 'R', 'l', 'D', '\ 0'}; // print the character array printf ("char array = % s \ n ", charArray );}