Today to say a C language array and string, why say this, because recently C language encountered some problems, today simply talk about the problems I have encountered.
First look at the structure and function,
Then asks the user to enter the name, the telephone number, the type and the email address, the user can circulate the input, here appears the first question. Since the user loops the input to exit, I set a condition when looping, while (s->name!= ' Q '), where S is the struct type, and if the user enters the letter Q, it exits. At first glance, this statement is not wrong, I then happy to debug, debugging the result is I got a dead loop, press "Q" will not quit. I do not forget, I am very confident that I wrote this no bug. So I added a printf after the scanf function, that is, every time I enter it, I print the content I typed directly. Continue testing, after entering Q, the print is Q, yes, but still a dead loop, that is, while (s->name!= ' Q '), the condition is not established. I am ignorant, print out of clearly is Q, but the cycle is not to quit, think for a long time did not think out, simply do not do, rest for a few days, and then go to do the website.
A few days later come back to look again, or feel that they write no bug, then change a judgment loop condition bar, in the function body set a char flag, also let the user input Q exit. Because of a bit of a long time, I forgot what was wrong here, if I remember correctly, this may be a C language bug, that is, when the external function uses the struct, let the user output, it will automatically skip the external function to define the input of the variable. What do you mean, I'll give you an example, a struct or a struct, a function that defines itself,
C-language arrays and strings