Is a int i legal in C?

Updated on technology 2024-04-06
28 answers
  1. Anonymous users2024-02-07

    Illegal. First of all, if int() is a function, it is obviously a duplicate of the keyword, so it is not a function.

    Secondly, if it's a cast, the form should be (int)i, and as for what is said above, it's probably their compiler.

    It's support for C++ and things like that.

  2. Anonymous users2024-02-06

    Legal, force type conversion, provided that the defined type of a is an integer.

  3. Anonymous users2024-02-05

    Legal, a=int(i); int() casts the type of i to the type int.

  4. Anonymous users2024-02-04

    Legal, obviously type casting.

  5. Anonymous users2024-02-03

    The legal one is the cast type.

  6. Anonymous users2024-02-02

    Type casts have been around in C and can continue to be used in C++. In C-style casting, the target data type is placed in a bunch of parentheses and then placed before the expression of the source data type. In C++, it is allowed to use the target data type as a function, and the source data type expression is placed in a pair of parentheses, which is known as a "function style" casting.

    There is no essential difference between the above two types of casting, except for a slight difference in the form of writing. Namely:

    t)expression //c-style castt(expression) //function-style cast

    a=int(i);C will report an error, and C++ is equivalent to a=(int)i;

  7. Anonymous users2024-02-01

    No. The inner after a cannot be empty, and the size of the array must be specified with a constant, such as: a[10] and so on.

    The inner cannot be empty either, there must be at least one element. Such as:

    int a[3]=;

    Or. int a[3]=;

    A semicolon (; Otherwise, there will be an error as well.

  8. Anonymous users2024-01-31

    The above opening comes to the top, as long as there is an initialization element in {}, it can be written like this. Strings are often initialized like this:

  9. Anonymous users2024-01-30

    No, the length of the array must be specified.

  10. Anonymous users2024-01-29

    if(a[i]) is the copy sentence body that performs the if judgment, a[i] is one.

    Value. In C++, there is an implicit type conversion where if a number is not 0, then it is converted to true, otherwise it is converted to false.

    Therefore, if(a[i]) is to determine whether a[i] is 0, and if it is 0, if(a[i]) is false, otherwise it will enter the if substatement.

  11. Anonymous users2024-01-28

    First of all, we have to think that if() is to judge the truth or falsehood of the conditions in (), then it is simple, to put it bluntly, the value of a[i] is true or false, I don't know what type of you a, as long as a[i] is not equal to 0, it returns true or not false

  12. Anonymous users2024-01-27

    int a,b;Define int variables, i.e., integer variables a, b

    a=1+'a';Because a is an int type, the character that follows'a'implicitly transforms to an int type, and a character'a'In ASCII code, it is 97, so a=1+97=98

    b=2+7%-4-'a';where 7%-4 is the remainder after 7 divided by -4, in C, whether a positive number is divided by a positive number or a negative number, the remainder obtained is always a positive number, and the quotient is taken downward, so the remainder is +3, in the ASCII code,'a'=65, in summary, b = 2 + 3-65 = -60

  13. Anonymous users2024-01-26

    I chose BA wrongly. The type is incorrect, ++p is int*, a[1] is int.

    b correct. dup++ only changes the value of the pointer p, not the value of the address that p points to.

    c error. The int type does not allow ++ operations.

    d error. The int type does not allow ++ operations.

    For example: ++p; Equivalent to a[1].

    The exact expression is that ++p points to an address that is &a[1]; Because preceded by p=a; That is, initially, let p point to the beginning address of a.

    Here ++ is the prefix plus plus, which should be added by 1 in the expression before being used, so it points to a[1].

    #include

    int main () here to make a storage space, the size of the array needs to be determined.

    p=a;+p;

    printf("%d %d",*p, a[1]);Output values.

    Output address. return(0);

  14. Anonymous users2024-01-25

    Both a++ and p++ are lvalues, and in a statement, they can only appear to the left of the assignment number. Theoretically, b, c, and d are all wrong.

    The legal operation is a.

    p;Equivalent to a[1].

    The exact expression is that ++p points to an address that is &a[1]; Because preceded by p=a; That is, initially, let p point to the beginning address of a.

    Here ++ is the prefix plus plus, which should be added by 1 in the expression before being used, so it points to a[1].

    #include

    int main () here to make a storage space, the size of the array needs to be determined.

    p=a;+p;

    printf("%d %d",*p, a[1]);Output values.

    Output address. return(0);}

  15. Anonymous users2024-01-24

    int *a is the definition of an integer pointer variable a.

    int a [ is not written in this way.

    int *a

    1. Define a as an array.

    2. The element of each array is a pointer pointing to an integer.

    int *)a casts the pointer variable a to an integer pointer, indicating that a is not usually an integer pointer, but can also be an integer pointer.

    int (*a)

    1. Definition A is a pointer.

    2. A points to an array of integers.

    Array creation: When creating an array, we must define the type and size of the array, the size of the array cannot be 0, and the elements in the array are all of the same type.

    int arr[10];The inside must be a constant constant expression (3+8) and cannot be a variable (x....

    Initialization of the array: When the array is created, we must also initialize the array.

    int arr1[3] =

    int arr2 Here, we don't need to write the number in arr[3];

    int arr3[3] = is also possible, just initialize the last number to 0.

    int arr4[3] = No, it cannot exceed the length of the array.

    char arr5[3] = Because it's a character type, 98 is actually a character'b'

    char arr6 abcdef";

    Features:

    1. An array is a collection of elements of the same data type.

    2. The storage of each element in the array is sequential, and they are stored together in memory in this order.

    3. The array element is represented by the name of the entire array and its own sequential position in the array. For example, a[0] represents the first element in an array with the name a, a[1] represents the second element of the array a, and so on.

  16. Anonymous users2024-01-23

    In this statement, ++a means to perform an auto-increment operation on variable a, first adding 1 to the value of a, and then assigning the value to c. Therefore, the value of c is the value of a plus 1, that is, 6

  17. Anonymous users2024-01-22

    int&

    a is the meaning of a reference, which is equivalent to one of the original variables.

    Copy. For example, intn=

    4;int&a=

    n;In this case, a and n are the same thing, and changing the value of a will change the value of n.

    Defining references in the parameters of a function also means the same thing. For example:

    voidfun(int&

    a);function intn=

    define the variable nfun(n);

    Call the fun function.

    In this case, using variable a in fun is equivalent to using variable n, changing the value of a in the function, the value of n will also change at the same time, and the reference is defined in the form parameter, which can be used as the output parameter.

    The advantage of defining a reference is that when you pass a value, the system will open up a new piece of memory to store the value of the input function, while using a reference skips this step, which is conducive to improving the efficiency of the program. This is especially important if the function is being passed into a large array.

    Of course, pointers can also do this, but references are more efficient to execute than pointers.

    If you don't need to change the value of the reference in the function, you can define void in this way

    fun(const

    int&a);

  18. Anonymous users2024-01-21

    In C++, nt &a means to define a reference.

    A reference is equivalent to a pointer and then a value, and both he and the referenced variable represent the same piece of memory.

    int&)a: The value of a in a memory cell is obtained without conversion.

    int)a: The value of a in memory is converted to an int type.

  19. Anonymous users2024-01-20

    When defining a variable, * denotes a pointer.

    For example, int * a, which means that a is a pointer to int int **a is equivalent to (int *) a, which means that a is a pointer to int * (in layman's terms, the value of a is a pointer, or address), that is, a pointer to int pointer, which is a level 2 pointer.

    int m = 1;

    int *p = &m;

    int **a = &p;

  20. Anonymous users2024-01-19

    nt &b = i;Here b is a reference, which is a reference to variable i, and the reference is a pointer, and there is no difference between the two. We.

    Think of the reference as if it's not needed"*"You can access the pointer of the variable, and the function completed by the above two programs is the same as that of the following program.

    Your int &a

    It should also be in the form of void function(int &a), passing arguments.

  21. Anonymous users2024-01-18

    When int* a and int* b are followed by semicolons, int* a; is a pointer a,int*b that declares or states that it points to an int variable; is a pointer b that declares or states that it points to an int variable. There is no semicolon after both in the question, which should be said to be a wrong statement. The jargon says it this way:

    int* a;is declaring int* pointer a, int* b; It is a declaration int* pointer b. Of course, understand that the type of pointer refers to the type of target it points to.

  22. Anonymous users2024-01-17

    int* is a pointer to int.

    char* is a pointer to char.

    A is a dereference to pointer A.

    char* p;is a pointer of type char*p = &c;Assign the address of c to p to point to the stored memory int b = 3;

    int* a = &b;take the address of b and assign the pointer a*a = 4; Change the memory content of the address pointed by a to 4, because a points to b, so after the execution of this sentence, b = 4

  23. Anonymous users2024-01-16

    &a is the memory address where a is stored, for example, the variable a=1, &a is equal to the value of the memory address where the 1 is stored A is the starting memory unit address of this array a, &a is the same as a You can see the reference below.

  24. Anonymous users2024-01-15

    Defines a pointer variable that points to the address of the integer data.

    For example: int*a;

    int b=10;

    a=&b;printf("%d",* a);

    The result is 10.

  25. Anonymous users2024-01-14

    In fact, int &a is the meaning of defining a pointer.

  26. Anonymous users2024-01-13

    The difference between int *a and int a [ is equivalent to the difference between a pointer and an array.

    The difference between a pointer and an array:

    2. The name of the array corresponds to (rather than points to) a piece of memory, and its address and capacity remain unchanged during its lifetime, and only the contents of the array can be changed. The pointer can point to any type of block of memory at any time, and it is characterized by:"Variable", so we often use pointers to manipulate dynamic memory.

    3. When an array is passed as an argument to a function, the array automatically degenerates into a pointer of the same type.

  27. Anonymous users2024-01-12

    A definition like int a is not syntactical. Unless int a=;

    int *a;It is a pointer that defines an int type and points to an address that is used to store int data.

    The name of the array means the start address of the array. It's not a question of whether there's a difference. They are simply used in different situations.

    You can use the array name to represent the nth element of the array *(a+(n-1)) You can also define a pointer to the nth element.

    int *p=&a[n-1];

    In the example you gave, it is legal to use a form parameter to represent a type. int a represents an array of integers.

  28. Anonymous users2024-01-11

    int*a refers to the definition of a pointer to int type data, and inta refers to the definition of an integer variable a, int*

    A is the same as INTA, but INT

    A is more rigorous, e.g., int

    a,b;Only a is a pointer variable.

    int*a,b;

    It's easy to think that A and B are both pointers.

Related questions
15 answers2024-04-06

Indicates that the remainder of 6 is taken.

In the C language, % stands for remainder (or modulo operation). >>>More

12 answers2024-04-06

This is an additive function I wrote that can judge overflow: >>>More

11 answers2024-04-06

Valid variable names for the C language:

First, it can only contain numbers, letters, and underscores. >>>More

8 answers2024-04-06

The semicolon is the sign of the end of the statement, but the semicolon is not used after the loop, if, and subfunctions such as long long a (int b), and everything else is used, but two semicolons cannot be added, although it will not cause an error, but it may affect the result.

13 answers2024-04-06

C language is a must language for programmers, and all languages are basically built on C language, it is the foundation of computer language, as a programmer must learn hard.