GCC and g++ in Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.