Using Xcode to implement the first C language program--hello World

Source: Internet
Author: User

have been using Xcode to learn Oc,swift recently. and develop iOS apps. Idle to dull, want to write a few C programs on the Mac. Once in Windows, we used Vc++,visual Studio, and so on C or C + + IDE. But what environment should we use to learn C when we come to the Mac? The answer is, of course, Xcode.

Xcode currently supports Swift in the language. Objective-c,c. Four kinds of C + +. Let's use Xcode to write a HelloWorld.

The detailed implementation process is as follows:

(1) Install command line Tool on Mac, if not installed please refer to my blog "Xcode command line Tools installation Method".

(2) Open Xcode, select "Create a new Xcode project", then in OS X, select Application below, and on the right side select "Command line Tool", for example to see:


(2) then enter the project name, select C in the following language, of course, there are several other languages to choose: Finally select the workspace, create it.


(3) After the project has been created. folder structure such as the following: we are very familiar with the. c File:


(4) Open main.c, can see very familiar C language code, the system has voluntarily generated a part of the code. Contains the output Hello world.

#include <stdio.h>int main (int argc, const char * argv[]) {    //Insert code    here ... printf ("Hello, world!\n");    return 0;}

The output results are as follows:


Summarize. Go through the above steps. Hello World, written in C in the context of Xcode, is done. Code it out for yourself.


Let me briefly explain the function result status return code. For the return value of a function, I am able to use some predefined constants such as the following:

#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define infeasible-1#define OVERFLOW-2



GitHub home: https://github.com/chenyufeng1991.

Welcome to visit us!



Using Xcode to implement the first C language program--hello World

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.