C-Language legal identifiers (hud2024)

Source: Internet
Author: User

Input method: Enter an integer type first, and then loop through the string with spaces.

Think: integer type with scanf_s () input. Cycle The character of the buffer with the getchar () function before entering the string. Then, enter a string with a space with the "gets_s ()" function. (Note that each string is entered as a whole ).

#include <stdio.h>#include<cstring>intMain () {intN; CharD; Charc[Wuyi];  while(scanf_s ("%d%c", &n,&d)! =EOF)        {GetChar ();  while(n--) {gets_s (c); inti =1; if(c[0] =='_'|| (c[0] >='a'&&c[0] <='Z') || (c[0] >='A'&&c[0] <='Z'))            {                 for(i =1; I < strlen (c); i++)                {                    if(C[i] = ='_')                        Continue; Else if(C[i] >='a'&&c[i] <='Z')                        Continue; Else if(C[i] >='A'&&c[i] <='Z')                        Continue; Else if(C[i] >='0'&&c[i] <='9')                        Continue; Else                         Break; }            }            if(I >=strlen (c)) printf ("yes\n"); Elseprintf ("no\n"); }    }}

C-Language legal identifiers (hud2024)

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.