Assuming you are on a linux / unix machine using the GNU toolchain, you can easily check this:
Copy the above code to test.c:
$ echo "int temp = temp +1;
int main()
{
return temp;
}" > test.c
Testing to check if it is really C (it is not):
$ gcc test.c
test.c:2: error: initializer element is not constant
Testing to make sure it is valid in C ++ (this!):
$ g++ test.c
Check return code:
$ ./a.out && echo "success: return code $?" || echo "failure: return code $?"
failure: return code 1
source
share