Confirm Buffer
To confirm the size of the set alignment or variable to avoid data chaos or cause the system. Please see the user input data: char city [10]; / * is the metropolitan name * / printf ("Enter a city name:"); scanf ("% s", city); printf ("city IS% S / N ", city; here, the urban name is set to 10 words (English characters). What if the user enters the urban name of 10 words or more? It can be said that the program fails or covers the data in the buffer. Anyway, don't take a risky thing, you have to check the length of the text: CHAR City [10]; / * is the arrangement of urban name * / Printf ("Enter a city name:"); Fgets (City, Sizeof (City) , stdin; Printf ("City IS% S / N", City; The above has been modified is: If the user enters the urban name of 10 words, only the length of the buffer can accept, the outside will not accept.