My name is Ricardo, please can you help me?
How can I compile the following ANSI C code without warnings:
#include <stdio.h>
void main(void)
{
printf("Hello world!\n");
}
I tryed:
gcc helloworld.c -o helloworld
The compiler answered:
helloworld.c: In function `main':
helloworld.c:4: warning: return type of 'main' is not `int'
I also tryed:
gcc -ansi helloworld.c -o helloworld
But...with the same warnings.
Other problem is with this C++ code:
#include <iostream>
void main(void)
{
cout << "Hello world!\n";
}
gcc helloworld.cpp -o helloworld
The compiler answered:
helloworld.cpp:4: error: `main' must return `int'
helloworld.cpp: In function `int main(...)':
helloworld.cpp:5: error: `cout' undeclared (first use this function)
helloworld.cpp:5: error: (Each undeclared identifier is reported only
once for each function it appears in.)
I also tryed:
gcc -ansi helloworld.cpp -o helloworld
But...with the same warnings.
Please these are basic ANSI C/C++ samples that I would like to compile
using gcc.
Please can you help me?
Thank you very much and best regards,
Ricardo