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