The first C + + program under Mac-helloworld__c++

Source: Internet
Author: User

Article Author: Tyan
Blog: noahsnail.com |  CSDN | Jianshu

Under Windows is accustomed to vs write C + + program, of course, also with the command line compiled program, under the Mac without the IDE installed, Use the terminal to write a HelloWorld.cpp file, do not know how to compile under the Mac, using the GCC command error, has written helloworld.c file, gcc compile execution is no problem. Check it out, in the Mac compiled C + + program can use clang++ or g++, I have two tried, are available. HelloWorld.cpp

#include <iostream>
using namespace std;
int main ()
{
   cout<< "Hello world!" <<endl;
   return 0;
}
clang++ compilation
# Compile
$ clang++-o HelloWorld HelloWorld.cpp 

# Execute
$/helloworld
Hello world!
g++ compilation
# Compile
$ g++-o HelloWorld HelloWorld.cpp 

# Execute
$/helloworld 
Hello world!
Related Article

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.