C language Easy to forget easy to ignore the knowledge point
There is a phenomenon of local short-circuit in logical operators
1.&& 1&&2 and operation of the same truth is true that there is a false if 1 is false then 2 do not judge
2.| | Or an operation that represents a true true and False is False if 1 | | 2, 1 is true, 2 doesn't judge.
Break is encountered in switch statement don't forget to write break
Note the extra character getchar () for character input, can be used to accept a character in the cache, or you can use Rewind (stdin) to empty the cache
3. Random function Arc4random () to [X, Y] obtains random number arc4random ()% (y-x+1) +x;
4.%s encountered ' "" to stop, the array do not poor students out of bounds
5. Char A[6] = {' A ', ' P ', ' P ', ' l ', ' e ', ' d '}; Remember to add ' yes ' if the string is automatically added ' "', ' char ' a[6] =" Apple ";
6. Strlen calculation of the length of the time encountered ' "and the end of the ' no '
String s[] = "Apple"; The number of elements is 6, but the length is 5, the string is automatically followed by a ' yes ', but the length of the calculation does not include ' the '.
7. Note: All involved in the comparison and assignment of strings cannot use > < or = These operators but rather use strcmp (String 1, string 2); strcpy (String 1, String 2) The functions of these strings, compute the length on the strlen, and in the structure also pay attention to the use of strcpy (Student.name, "Lili");
8.char *p = "ios"; *p = ' A '//This is wrong, point to the constant area address, modify the constant area of the address, which is not allowed, will happen to crash
9. In memory allocation if the length of the string is computed, and memory is allocated according to the length of the string, it is remembered that the length of the string is not prefixed with a ' yes ', so remember to add 1 to the calculation of the function.
10. When assigning values to the string, note that the final ' ' is ' to be added