My C notebook


In [1]:
#include <stdio.h>

int main() {
    printf("Hello world\n");
}



Hello world

Triggering warning

When we trigger a warning by removing the needed include we see the following


In [2]:
int main() {
    printf("Hello world\n");
}


/tmp/tmpehgve74i.c: In function ‘main’:
/tmp/tmpehgve74i.c:2:5: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
     printf("Hello world\n");
     ^
/tmp/tmpehgve74i.c:2:5: warning: incompatible implicit declaration of built-in function ‘printf’
/tmp/tmpehgve74i.c:2:5: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
Hello world

Triggering error

When we trigger an error by removing a needed semicolon we see the following


In [3]:
#include <stdio.h>

int main() {
    printf("Hello world\n")
}


/tmp/tmpy43hek50.c: In function ‘main’:
/tmp/tmpy43hek50.c:5:1: error: expected ‘;’ before ‘}’ token
 }
 ^
[C kernel] GCC exited with code 1, the executable will not be executed