To write a small C + + program on Linux today, you need to use the cout in iostream, start by creating a hello.c file to write the following code:
1#include <stdio.h>2#include <sys/types.h>3#include <unistd.h>4#include <iostream>5 using namespacestd;6 intMain ()7 {8 inti;9 for(i=0;i<3; i++)Ten { One fork (); A //printf ("H"); -cout <<"H"; - } the return 0; -}View Code
Compiling the code through GCC will cause errors that cannot be passed. Then I think that under Windows C + + source files are. cpp type, I think it is not my own file suffix problem, so instead of hello.cpp, and then compile again, still can't pass (I was compiled with GCC) ... After a few tossing, I suddenly think of Linux and there is a g++ compiler tool, I used g++ tried once. Hey, there's no problem this time.
From this small example know, Linux under C and C + + still need to go very well to other ...
GCC and g++ in Linux