Errors
in programming with C
Error
1
Because
start of normal bracket is removed after main
hello.c:2:9: error:
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘)’ token
2 | int main)
| ^
Error
2
Because
; removed after Printf Line
hello.c:4:25: error:
expected ‘;’ before ‘return’
4 |
printf("Hello World\n")
|
^
|
;
5 | return 0;
| ~~~~~~
Error
3
Because
; removed after Return 0
hello.c: In function
‘main’:
hello.c:5:10: error:
expected ‘;’ before ‘}’ token
5 | return 0
| ^
| ;
6 | }
| ~
Error
4
Because
we have removed } bracket at the end
hello.c: In function
‘main’:
hello.c:5:2: error:
expected declaration or statement at end of input
5 | return 0;
| ^~~~~~
Error
5
Because
we have removed { bracket
hello.c: In function
‘main’:
hello.c:4:2: error:
expected declaration specifiers before ‘printf’
4 |
printf("Hello World\n");
| ^~~~~~
hello.c:5:2: error:
expected declaration specifiers before ‘return’
5 | return 0;
| ^~~~~~
hello.c:6:1: error:
expected declaration specifiers before ‘}’ token
6 | }
| ^
hello.c:6: error:
expected ‘{’ at end of input
6 | }
|
Error 6
Because
we have removed “ before hello
hello.c: In function ‘main’:
hello.c:4:9: error: ‘Hello’
undeclared (first use in this function); did you mean ‘ftello’?
4 | printf(Hello
World\n");
| ^~~~~
| ftello
hello.c:4:9: note: each
undeclared identifier is reported only once for each function it
appears in
hello.c:4:14: error: expected
‘)’ before ‘World’
4 | printf(Hello
World\n");
| ^~~~~~
| )
hello.c:4:20: error: stray ‘\’
in program
4 | printf(Hello
World\n");
| ^
hello.c:4:22: warning: missing
terminating " character
4 | printf(Hello
World\n");
| ^
hello.c:4:22: error: missing
terminating " character
4 | printf(Hello
World\n");
|
^~~
hello.c:5:11: error: expected
‘;’ before ‘}’ token
5 | return 0;
| ^
| ;
6 | }
| ~
Error
7
Because
we have removed P of printf
hello.c: In function ‘main’:
hello.c:4:2: warning: implicit
declaration of function ‘rintf’ [-Wimplicit-function-declaration]
4 | rintf("Hello
World\n");
| ^~~~~
hello.c:4:2: warning:
incompatible implicit declaration of built-in function ‘rintf’
hello.c:2:1: note: include
‘<math.h>’ or provide a declaration of ‘rintf’
1 | #include<stdio.h>
+++ |+#include <math.h>
2 | int main()
hello.c:4:8: error:
incompatible type for argument 1 of ‘rintf’
4 | rintf("Hello
World\n");
| ^~~~~~~~~~~~~~~
| |
| char *
hello.c:4:8: note: expected
‘float’ but argument is of type ‘char *’
Error 8
Because
we have removed 0 after return
hello.c:5:2: warning: ‘return’
with no value, in function returning non-void
5 | return ;
| ^~~~~~
hello.c:2:5: note: declared
here
2 | int main()
| ^~~~
Error
9
Because
we have int Before main()
hello.c:2:1: warning: return
type defaults to ‘int’ [-Wimplicit-int]
2 | main()
| ^~~~
Error
10
Because
we have have removed > after stdio.h
hello.c:1:17: error: missing
terminating > character
1 | #include<stdio.h
|
Error
11
Because
we have removed include from #include <stdio.h>
hello.c:1:2: error: invalid
preprocessing directive #<
1 | #<stdio.h>
| ^
hello.c: In function ‘main’:
hello.c:4:2: warning: implicit
declaration of function ‘printf’
[-Wimplicit-function-declaration]
4 | printf("Hello
World\n");
| ^~~~~~
hello.c:4:2: warning:
incompatible implicit declaration of built-in function ‘printf’
hello.c:1:1: note: include
‘<stdio.h>’ or provide a declaration of ‘printf’
+++ |+#include <stdio.h>
1 | #<stdio.h>
Error
12
Because
we have removed # before include
hello.c:1:8: error: expected
‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before
‘<’ token
1 | include<stdio.h>
| ^
Error
13
Because
we have removed . In between stdio and h
ello.c:1:9: fatal error:
stdioh: No such file or directory
1 | #include<stdioh>
| ^~~~~~~~
compilation terminated.
Error 14
Because
we have removed space in between int and main
hello.c:2:1: warning: return
type defaults to ‘int’ [-Wimplicit-int]
2 | intmain()
| ^~~~~~~
/usr/bin/ld:
/usr/lib/gcc/x86_64-redhat-linux/9/../../../../lib64/crt1.o: in
function `_start':
(.text+0x24): undefined
reference to `main'
collect2: error: ld returned 1
exit status
Error
15
Because
we have given space between print and f
hello.c: In function ‘main’:
hello.c:4:2: error: unknown
type name ‘print’; did you mean ‘int’?
4 | print f("Hello
World\n");
| ^~~~~
| int
hello.c:4:10: error: expected
declaration specifiers or ‘...’ before string constant
4 | print f("Hello
World\n");
|
^~~~~~~~~~~~~~~
Error
16
Because
we have given space between \ and n
hello.c:4:9: warning: unknown
escape sequence: '\040'
4 | printf("Hello
World\ n");
|
^~~~~~~~~~~~~~~~
Error 17
Because
we have given space
between stdio and .h
hello.c:1:9: fatal error: stdio
.h: No such file or directory
1 | #include<stdio .h>
| ^~~~~~~~~~
compilation terminated.
Error
18
Because
we have written complete program in single line
hello.c:1:20: warning: extra
tokens at end of #include directive
1 | #include<stdio.h>
int main() { printf(" Hello World \n"); return 0; }
| ^~~
/usr/bin/ld:
/usr/lib/gcc/x86_64-redhat-linux/9/../../../../lib64/crt1.o: in
function `_start':
(.text+0x24): undefined
reference to `main'
collect2: error: ld returned 1
exit status
Error
19
Because
we have started bracket { before int main()
hello.c:2:1: error: expected
identifier or ‘(’ before ‘{’ token
2 | {
| ^
Error
20
Because
we have removed int main from program
hello.c:2:1: error: expected
identifier or ‘(’ before ‘{’ token
2 | {
| ^
Bug Number : 1
Bug : Remove # from include statement
Error : expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token include<stdio.h>
Bug Number : 2
Bug : Missing letter from keyword – using include or remove include
Error : invalid preprocessing directive #includ; did you mean #include? #includ<stdio.h>
Bug Number : 3
Bug : Missing closing angle bracket
Error : missing terminating > character #include<stdio.h
Bug Number : 4
Bug : Missing .h extension name from header file name
Error : stdio.: No such file or directory #include<stdio.>
Bug Number : 5
Bug : Remove # from header file and add & operator before include
Error : expected identifier or ‘(’ before ‘&’ token &include<stdio.h> or
Bug Number : 6
Bug : int keyword is wrong – nt
Error : unknown type name ‘nt’; did you mean ‘int’? nt main(){
Bug Number : 7
Bug : Passing int datatype as parameter in function main
Error : parameter name omitted int main(int){
Bug Number : 8
Bug : Passing numeric value as parameter in function main
Error : 1. error: expected declaration specifiers or ‘...’ before numeric constant int main(2){
2. expected identifier or ‘(’ before numeric constant
Bug Number : 9
Bug : Missing opening braces from main function
Error : 1. expected ‘{’ at end of input
2. expected declaration specifiers before ‘printf’ printf("statement");
3. expected declaration specifiers before ‘return’ return 0;
4. expected declaration specifiers before ‘}’ token }
Bug Number : 10
Bug : Missing letter in printf keyword
Error : incompatible type for argument 1 of ‘rintf’ rintf("statement");
Bug Number : 11
Bug : Missing “ from string encapsulation from printf statement
Error : expected expression before return statement
Bug Number : 12
Bug : Return any character ‘x’ from return statement
Error : x’ undeclared (first use in this function) return x;
Bug Number : 13
Bug : Write main function twice in the program
Error : redefinition of ‘main’ int main(){
Bug Number : 14
Bug : used int datatype twice as return type
Error : two or more data types in declaration specifiers int int main(){
Bug Number : 15
Bug : Do not pass any single parameter in printf function
Error : too few arguments to function ‘printf’ printf();
Bug Number : 16
Bug : Used [ instead of < at the time of including header file
Error : #include expects "FILENAME" or <FILENAME> #include[stdio.h]
Bug Number : 17
Bug : Replaced # with integer constant value
Error : invalid suffix "include" on integer constant 1include<stdio.h>
Bug Number : 18
Bug : Empty at the place of header file name
Error : empty filename in #include #include<>
Bug Number : 19
Bug : If used multiple line comment after including header file
Error : unterminated comment /*int main(){
Bug Number : 20
Bug : using small bracket twice after main function keyword
Error : ‘main’ declared as function returning a function int main()(){
1:
Bug:
remove # from
include statement
Error:
hello.c:1:8: Error:
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘<’ token
1 |
include<stdio.h>
| ^
2.
Bug:
remove include
statement
Error:
hello.c: In
function ‘main’:
hello.c:5:2:
warning: implicit declaration of function ‘printf’
[-Wimplicit-function- declaration]
5 |
printf("Hello Everyone\n");
| ^~~~~~
hello.c:5:2:
warning: incompatible implicit declaration of built-in function
‘printf’
hello.c:1:1: note:
include ‘<stdio.h>’ or provide a declaration of ‘printf’
+++ |+#include
<stdio.h>
3.
Bug:
remove .h from
include statement
Error:
hello.c:2:9: fatal
Error: stdio: No such file or directory
2 |
#include<stdio>
4.
Bug:
remove stdio.h from
include statement
Error:
hello.c:2:9:
Error: empty filename in #include
2 | #include<>
| ^~
hello.c: In
function ‘main’:
hello.c:5:2:
warning: implicit declaration of function ‘printf’
[-Wimplicit-function- declaration]
5 |
printf("Hello Everyone\n");
| ^~~~~~
hello.c:5:2:
warning: incompatible implicit declaration of built-in function
‘printf’
hello.c:1:1: note:
include ‘<stdio.h>’ or provide a declaration of ‘printf’
+++ |+#include
<stdio.h>
5.
Bug:
remove > from
include statement
Error:
hello.c:2:17:
Error: missing terminating > character
2 |
#include<stdio.h
6.
Bug:
remove < from
include statement
Error:
hello.c:2:10:
Error: #include expects "FILENAME" or <FILENAME>
2 | #include
stdio.h>
|
^~~~~
hello.c: In
function ‘main’:
hello.c:5:2:
warning: implicit declaration of function ‘printf’
[-Wimplicit-function- declaration]
5 |
printf("Hello Everyone\n");
| ^~~~~~
hello.c:5:2:
warning: incompatible implicit declaration of built-in function
‘printf’
hello.c:1:1: note:
include ‘<stdio.h>’ or provide a declaration of ‘printf’
+++ |+#include
<stdio.h>
7.
Bug:
remove include from
include statement
Error:
hello.c:2:2: Error:
invalid preprocessing directive #<
2 | # <
stdio.h>
| ^
hello.c: In
function ‘main’:
hello.c:5:2:
warning: implicit declaration of function ‘printf’
[-Wimplicit-function- declaration]
5 |
printf("Hello Everyone\n");
| ^~~~~~
hello.c:5:2:
warning: incompatible implicit declaration of built-in function
‘printf’
hello.c:1:1: note:
include ‘<stdio.h>’ or provide a declaration of ‘printf’
+++ |+#include
<stdio.h>
8.
Bug:
replcae stdio with
stdio1 in include statement
Error:
hello.c:2:9: fatal
Error: stdio1.h: No such file or directory
2 |
#include<stdio1.h>
9.
Bug:
remove int from
main function
Error:
hello.c:3:2:
warning: return type defaults to ‘int’ [-Wimplicit-int]
3 | main()
10.
Bug:
replace int with
void in main function
Error:
hello.c: In
function ‘main’:
hello.c:6:9:
warning: ‘return’ with a value, in function returning void
6 | return 0;
| ^
hello.c:3:7: note:
declared here
3 | void
main()
11.
Bug:
replace main with
main1 in main function
Error:
/usr/bin/ld:
/usr/lib/gcc/x86_64-redhat-linux/9/../../../../lib64/crt1.o: in
function `_start':
(.text+0x24):
undefined reference to `main'
collect2: Error: ld
returned 1 exit status
12.
Bug:
remove main from
main function
Error:
hello.c:3:7: Error:
expected identifier or ‘(’ before ‘)’ token
3 | int ()
13.
Bug:
add I in () in main
function
Error:
hello.c: In
function ‘main’:
hello.c:3:6:
warning: type of ‘i’ defaults to ‘int’ [-Wimplicit-int]
3 | int
main(i)
14.
Bug:
replace int with
int char in main function
Error:
hello.c:3:5:
Error: two or more data types in declaration specifiers
3 | int char
main()
15.
Bug:
add sdssd after ()
in main function
Error:
hello.c: In
function ‘main’:
hello.c:3:12:
Error: expected declaration specifiers before ‘dsfsad’
3 | int
main()dsfsad
|
^~~~~~
hello.c:7: Error:
expected ‘{’ at end of input
7 | }
16.
Bug:
add char in () in
main function
Error:
hello.c: In
function ‘main’:
hello.c:3:11:
Error: parameter name omitted
3 | int
main(char)
17.
Bug:
add() after () in
main function
Error:
hello.c:3:6:
Error: ‘main’ declared as function returning a function
3 | int
main()()
18.
Bug:
insert () inside
() int main function
Error:
hello.c:3:11:
Error: expected declaration specifiers or ‘...’ before ‘(’
token
3 | int
main(())
19.
Bug:
replace int with
asdf in main function
Error:
hello.c:3:1:
Error: unknown type name ‘asa’
3 | asa
main()
20.
Bug:
replace # with @
in include statement
Error:
hello.c:2:1:
Error: stray ‘@’ in program
2 | @include
<stdio.h>
@page { size: 21cm 29.7cm; margin: 2cm }
p { margin-bottom: 0.25cm; line-height: 115%; background: transparent }
21.
Bug:
remove f from
printf statement
Error:
hello.c: In
function ‘main’:
hello.c:5:2:
warning: implicit declaration of function ‘print’; did you mean
‘printf’? [-Wimplicit-function-declaration]
5 |
print("Hello Everyone\n");
| ^~~~~
| printf
22.
Bug:
remove “ from
printf statement
Error:
hello.c: In
function ‘main’:
hello.c:5:9:
Error: ‘Hello’ undeclared (first use in this function); did you
mean ‘ftello’?
5 |
printf(Hello Everyone\n");
|
^~~~~
|
ftello
hello.c:5:9: note:
each undeclared identifier is reported only once for each function it
appears in
hello.c:5:14:
Error: expected ‘)’ before ‘Everyone’
5 |
printf(Hello Everyone\n");
|
^~~~~~~~~
|
)
hello.c:5:23:
Error: stray ‘\’ in program
5 |
printf(Hello Everyone\n");
|
^
hello.c:5:25:
warning: missing terminating " character
5 |
printf(Hello Everyone\n");
|
^
hello.c:5:25:
Error: missing terminating " character
@page { size: 21cm 29.7cm; margin: 2cm }
p { margin-bottom: 0.25cm; line-height: 115%; background: transparent }
5 | printf(Hello Everyone\n");
|
^~~
hello.c:6:11:
Error: expected ‘;’ before ‘}’ token
6 | return 0;
23.
Bug:
remove 0 from
return statement
Error:
hello.c: In
function ‘main’:
hello.c:6:2:
warning: ‘return’ with no value, in function returning non-void
6 | return ;
| ^~~~~~
hello.c:3:6: note:
declared here
3 | int
main()
24.
Bug:
return a in return
statement
Error
hello.c: In
function ‘main’:
hello.c:6:9:
Error: ‘a’ undeclared (first use in this function)
6 | return a;
25.
Bug:
return “a”
instead of return 0
Error:
hello.c: In
function ‘main’:
hello.c:6:9:
warning: returning ‘char *’ from a function with return type
‘int’ makes integer from pointer without a cast
[-Wint-conversion]
6 | return
"a";
It looks like you're new here. If you want to get involved, click one of these buttons!