1 C Legal Identifier Enter a string to determine whether it is a legal identifier for C

Updated on technology 2024-03-26
14 answers
  1. Anonymous users2024-02-07

    1. Use Chinese as identifier, the premise is that the compiler supports Chinese as identifier, after C++11, the universal character name covers Chinese characters.

    2. When using Chinese as the identifier, its header file is the same as the original.

    3. The namespace in the program remains the same.

    4. The reserved word can be defined as Chinese and defined by define.

    5. You can use the type name to directly define the variable name in Chinese.

    6. The use of Chinese identifiers is the same as that of ordinary identifiers.

  2. Anonymous users2024-02-06

    1. Use Chinese as Peiye identifier, the premise is that the compilation posture machine supports Chinese as identifier, and after C++11, the universal character name covers Chinese characters.

    2. When using Jizhonghe Chinese as an identifier, its header file is the same as the original.

    3. The namespace in the program remains the same.

    4. The reserved word can be defined as Chinese and defined by define.

    5. You can use the type name to directly define the variable name in Chinese.

    6. The use of Chinese identifiers is the same as that of ordinary identifiers.

  3. Anonymous users2024-02-05

    Answer] :d Answer] d. Analysis:

    The legal identifier in the C language can only be composed of numbers, letters, and underscores, and one or two of them can be missing, but there can be no other symbols in the type, and the first character of the legal identifier must be a letter or an underscore. Therefore d is correct.

  4. Anonymous users2024-02-04

    1. Use Chinese as an identifier.

    The premise of this is the compiler.

    Support Chinese as identifiers, after C++11, universal character names cover Chinese characters.

    2. When using Chinese as an identifier, its header file.

    Same as the original.

    3. The namespace in the program remains the same.

    4. The reserved word can be defined as Chinese and defined by define.

    5. You can use the type name to directly define the variable name in Chinese.

    6. The use of Chinese identifiers is the same as that of ordinary identifiers.

  5. Anonymous users2024-02-03

    #include ""//if the vc++,with this line.

    #include ""

    int main(void){

    char a[50];

    int i;

    while(gets(a)){

    if(!(a[0]>='a' &&a[0]<='z' ||a[0]>='a' &&a[0]<='z' ||a[0]=='_'If it doesn't start with a letter or underscore, it's not.

    printf("no");

    else{for(i=1;a[i];i++) If there are non-letters, numbers, or underscores in the middle, it is not.

    if(!(a[i]>='a' &&a[i]<='z' ||a[i]>='a' &&a[i]<='z' ||a[i]=='_' ||a[i]>='0' &&a[i]<='9')){

    printf("no");

    break;

    if(a[i]=='\0'Excluding the above, the rest is certain.

    printf("yes");

    return 0;

  6. Anonymous users2024-02-02

    You list the keywords of the C language and put them in the array, first compare those that are not in this array, and then intercept the input string, the first one must be a letter or an underscore, and then iterate over whether each character of this string is legal, just judge it with multiple ifs.

  7. Anonymous users2024-02-01

    char is defined.

    The C language identifier consists of letters (a-z, a-z), numbers (0-9), and an underscore "", and the first character cannot be a number, but can be a letter or an underscore. For example, the correct identifiers: abc, a1, prog to.

    C keywords cannot be used as user identifiers, such as if, for, while, etc.

    The length of the identifier is determined by the compilation system on the machine, and the general limit is 8 characters (note: the 8 character length limit is the C89 standard, the C99 standard has been extended in length, in fact, most industry standards are longer).

    Identifiers are case-sensitive, i.e., strictly case-sensitive. Generally, variable names are lowercase, and symbolic constants are named.

    The identifier should be named in a way that "knows what the name is", e.g., length, sum, sum, pi, ......

    If my answer is helpful to you, please give a thumbs up (in the lower left corner), I look forward to your like, your efforts are very important to me, and your support is also the motivation for my progress. If you feel that my answer is still satisfactory, you can click on my avatar for one-on-one consultation. Finally, I wish you good health and a good mood.

  8. Anonymous users2024-01-31

    Legal identifier: Consists of letters, digits, and underscores and must begin with a letter or underscore.

    Invalid identifiers: Keywords cannot be used, identifiers cannot be the same as library functions, numbers cannot be prefaced, and special characters cannot be used.

    Hope it helps!!

  9. Anonymous users2024-01-30

    Identifiers in C are made up of letters, numbers, and underscores.

    The identifier cannot begin with a letter, and the identifier cannot be the same as a keyword in C (e.g., int, double).

    Here's the correct identifier:

    a,_a,a1,_a1

    The following is the wrong identifier:

    1a,float,a#

  10. Anonymous users2024-01-29

    1. The identifier consists of a-z, a-z, 0-9 and (underscore).

    2. Numbers cannot be used as identifiers, and in principle, they do not need to be used as the beginning.

    3. The identifier cannot be the same as the C language keyword.

  11. Anonymous users2024-01-28

    The legal identifiers for the c language are defined as:

    1 It can only consist of three characters: numbers, letters, and underscores;

    2 Cannot start with a number;

    3 Must not have the same name as the keyword.

    So: 1) 2ABCD starts with a number, violation.

    2) int is the keyword that represents integers in C.

    3) a-2c, not allowed to have - present in the identifier.

    456xy, which is not a valid identifier component.

    Therefore, only char is a valid identifier.

  12. Anonymous users2024-01-27

    dThe variable names, function names, labels, etc., used in the program are collectively referred to as identifiers. Except for the function name of the library function, which is defined by the system, the rest is defined by the user. c Specifies that an identifier can only be a string of letters (a z, a z), numbers (0 9), and an underscore (), and that its first character must be a letter or underscore.

    The following must also be noted when using identifiers:

    1) Standard C does not limit the length of identifiers, but it is limited by various versions of the C compilation system, as well as by the specific machine. For example, if the first eight bits of an identifier are valid in a certain version c, when the first eight bits of two identifiers are the same, they are considered to be the same identifier.

    2) In identifiers, there is a difference between case and case. For example, book and book are two different identifiers.

    3) Although identifiers can be defined by programmers at will, identifiers are symbols used to identify a certain quantity. Therefore, the name should be as meaningful as possible to facilitate reading comprehension and "as the name suggests".

  13. Anonymous users2024-01-26

    d.A starts with a number, b is a keyword, c has -, and e starts with . None of these are legal.

  14. Anonymous users2024-01-25

    Make the question clearer, I can't understand what the options of your question are.

Related questions
8 answers2024-03-26

C major is the standard note, 1=c is the do in the piece, and doc major is the standard key on the piano keys, and the minor key is A minor. C major refers to the first note of the note C. A minor is the first note with the note la. >>>More

9 answers2024-03-26

A skills are attack skills.

Category B skills are obstacle skills. >>>More

16 answers2024-03-26

Definition of a for loop.

for(the initial value of the variable; termination of operating conditions; The initial value of the first cycle i is 0, and it runs until i=3 stops i=2, and the condition is still satisfied, and the loop body is still executed, and the step size is 1+1 each time >>>More

9 answers2024-03-26

Hey! This is a very simple function to write, Your Excellency is estimated to have just learned data structures, now learn sorting, lookup, it's easy to give me a reward of two hundred points, I'll help you write it right away. >>>More

7 answers2024-03-26

It's called the [batch] program, in fact, don't think that the program you mentioned above to deal with garbage is really powerful, it's amazing, when you have learned DOS, that program can be said to be a very simple thing; >>>More