Home > Back-end >  Who to explain this code? Why can run
Who to explain this code? Why can run

Time:10-04

#include
#include
Int main ()
{
Int * c;
C=(int *) malloc (100 * sizeof (int));
* c=2;
Int * a=c;
Int b, e;
E=b [a];
Printf (" % d \ n ", e);
}

CodePudding user response:

Compiled without error code, of course I can run, you can run so the correct code, to learn the basis of C language, it is easy to understand these simple code, b is a little difficult [a], is actually a [b]

CodePudding user response:

B [a] is a [b]??

CodePudding user response:

If I haven't heard of this, it shows that the C language is the primary level, write a few lines of code to test by yourself, you know, for example:

Int a [3]={1, 2, 3};
Int b=2;
ShowMessage (b [a]);

Of course according to general habit to write code, don't write in turn.

CodePudding user response:

Little ga, understanding, because,
[b]=* (a + b)=* (b + a)=b [a]
Senior now,,,
C language to play for many years, also didn't see it, and your code to compile? Declare variables below the statement execution, and this is the c + + way,

CodePudding user response:

B [a] this, in turn, might already be on the tall?

CodePudding user response:

Is too high, I saw b, just don't think the initialization, it should be very hot hot hot hot

CodePudding user response:

Int b, e;
E=b [a];

This is not in conformity with the conventional, obviously wrong

CodePudding user response:

reference 4 floor ytfhwfnh response:
windbag honk, understanding, because of,
[b]=* (a + b)=* (b + a)=b [a]
Senior now,,,
C language to play for many years, also didn't see it, and your code to compile? Declare variables below the statement execution, and this is the c + + way,

This,,,,,,,

CodePudding user response:

Really can run but I see someone is c + + compiler code is write yes also simplify written out didn't pay attention to so many

CodePudding user response:

reference 4 floor ytfhwfnh response:
windbag honk, understanding, because of,
[b]=* (a + b)=* (b + a)=b [a]
Senior now,,,
C language to play for many years, also didn't see it, and your code to compile? Declare variables below the statement execution, and this is the c + + way,


Want to run in the old C compiler just let it be:
 
#include
#include
Int main ()
{
Int * c;
C=(int *) malloc (100 * sizeof (int));
* c=2;
{
Int * a=c;
Int b, e;
E=b [a];
Printf (" % d \ n ", e);
}
}
Prev:c
  • Related