"Xcode C-1" how to practice C with Xcode and practice an output sample, 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 a domain name inverted, such as www.hellocation.com. So write Com.hellocation.

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



(3) After entering the program, click MAIN.C Program source file, there is a ready-made HelloWorld program, directly click Cmd+b to compile. With output hello,world! Of course, we generally do it by pressing CMD+R instead of compiling and executing it first.


After compiling, a running file is generated under the products, and right-clicking can find the file in the Finder. is a UNIX executable file, the double-click will then open and run the terminal form.


(4) Output example: Although the other is only one line, but we are in the development of "code readable" as the first principle. 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) practice the C language in Xcode. Ability to write functions that need to be called, although this does not conform to the C99 development specification. However, this is done in Xcode (despite warnings).

b) The program can only have one main function.

c) in printf () the need to use the double-cited "", the use of single-cited "the program is hung off."

d) keyword is the language that comes with it, and the identifier is the name we take. Of course, the name has some rules, the most important thing is not to keyword conflict. Naming also has specifications, usually the hump name or use-or _ and so on connection.

e) A line of staring is//. MultiRow Stare is */*, of course, the single-line gaze shortcut is cmd+? Single Gaze can nest multiple lines of gaze. MultiRow gaze and nested single-line gaze. Develop a good habit of gazing.


"Xcode C-1" how to practice C with Xcode and practice an output sample, 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.