This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC Compile Failure


> Hello GCC Helpers,
> 
> This is a program I wrote:
> 
> #include <glibc>
> #include <stdio.h>
> void cout();
> main()
> {printf "Hello World. /n";
> 	cout << "Hello/n";
> return 0;
> }
> 

cout is not a function, it is an object. You can't declare it like this.
Second, you wrote C++ code, and you are compiling it using C compiler
(use g++ command instead of gcc). Third there is no such library glibc,
I think you meant stdlib.h. The correct code might look like this:

#include <iostream>
#include <stdio.h>
int main()
{
   printf("Hello World. \n");
   std::cout << "Hello\n";
   return 0;
}

Arturas M.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]