Recently you've been using Xcode to learn oc,swift and develop iOS apps. Idle to dull, want to write a few C programs on the Mac. Previously in Windows, we used to use vc++,visual Studio, and so on C or C + + ides, but what environment should we use to learn C in a Mac? The answer is, of course, Xcode. Xcode currently supports a swift,objective-c,c,c++ of four languages. Let's use Xcode to write a HelloWorld.
The specific implementation steps are as follows:
(1) Install command line Tool on Mac, if not installed, please refer to my other blog "Command line tools installation Method" in Xcode.
(2) Open Xcode, select "Create a new Xcode project", then under OS X, select Application, and on the right, select "Command line Tool" as shown in:
。
(2) then enter the project name, in the following language select C, of course, there are several other languages can choose: Finally select the workspace, create.
。
(3) After the project is created, the directory structure is as follows: We are very familiar with the. c File:
。
(4) Open main.c, you can see the very familiar C language code, the system has automatically generated a part of the code, including 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:
。
Summing up, after the above steps, we in the Xcode environment in C language written by the Hello World is done. Code it out for yourself.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Using Xcode to implement the first C language program--hello World