"Xcode C-1" how to Practice C language with Xcode and practice an output example, as well as important considerations

Source: Internet
Author: User

Learn the C language directly with Xcode and lay the groundwork for iOS development.

(1) Select OS X >>> application >>> Command line Tool



(2) Enter the product name, the company unique identification. Application unique identity = Company Unique identity + product name.

Note: The company's unique identity is usually the domain name inverted write, such as www.hellocation.com, then written com.hellocation.

Note: Select the C language. The default is OC, so we didn't do any action when we were learning oc.



(3) After entering the program, click MAIN.C Program source file, there is a ready-made HelloWorld program, directly click Cmd+b to compile, there is output hello,world! of course we are generally directly press cmd+r run, rather than compile and then run.


After compiling, an executable file is generated under the products, right-click to find the file in the Finder, a UNIX executable, double-click to open and execute the terminal window.


(4) Output example: Although the second type has only one row, we use "code readability" as the first principle in development. So the first one is recommended.

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

Precautions:

A) practicing C in Xcode, you can write the function that needs to be called back, although this does not conform to the C99 development specification, but still runs in Xcode (although there is a warning).

b) The program can have only one main function.

c) in printf (), you need to use the double quotation mark "", the single quotation mark ", the program will be hung off.

d) The keyword is the language comes with, the identifier is we take the name, of course, the name has some rules, the most important thing is not in the keyword conflict. The naming also has the specification, is usually the hump name or uses-or _ and so on connection.

e) A line of comments is//, multiline comment is/* */, of course, the single-line comment shortcut key is cmd+? Single-line comments can nest multiple lines of comments, multiline comments, and nested single-line comments. Develop a good habit of commenting.


"Xcode C-1" how to Practice C language with Xcode and practice an output example, as well as important considerations

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.