I am new to using gdb so I wanted to start by using a simple program that prints "Hello"
#include<stdio.h>
main(){
printf("Hello!\n");
}
saving as hello.c and then typing gdb. Once opened, based from tutorials, I type "file hello.c" in order to load the program into the debugger, but I get this message:
This GDB was configured as "x86_64-linux-gnu".
"hello.c": not in executable format: File format not recognized
So I typed in the "gcc -Wall -g hello.c -o hello" and got this message:
hello.c:3:1: warning: return type defaults to âintâ [-Wreturn-type] hello.c:
In function âmainâ: hello.c:6:1: warning: control reaches end of non-void function [-Wreturn-type]
so then I edited main with int main and added return 0 in the code. I did it again, no errors so I typed gdb ./hello and it worked...should I always have my mains as int main with the return 0 included?
int main()or preferablyint main (int argc, char**argv)return 0;before the closing brace}