C-language arrays and strings

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.