Now let's look at the following example.
#include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { printf("hello world \n"); return 0; } { printf("do you see this?!\n"); }
If you compile the above program, it will give you the following error:
$ gcc qc qc:10:1: error: expected identifier or '(' before '{' token $
This is because the gcc compiler expects identifier to { . Therefore, we need to update the above program as follows
#include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { printf("hello world \n"); return 0; } void function() { printf("do you see this?!\n"); return; }
It will work fine.
$ gcc qc $ ./a.out hello world $
Hope this helps!
source share