OC Basics Review 01-First OC Program

Source: Internet
Author: User

Recent brief review under OC Open iterm Tool Input command

mkdir Reviewoc

Open Sublime text file

Open-a sublime\ Text

Write the following code:

1 #include <stdio.h>2//main entry for all Programs  haha, not here. 3int Main () 4 {5     printf ("Hello OC \ n"); 6 }

Save As REVIEW01.M

Compile files in the Reviewoc directory cc-c review01.m

File without errors directly produces a REVIEW01.O file

Then execute the CC REVIEW01.O file

Generate executable file a.out

Execute command:./a.out

See the results as follows:

Correct output ha

It's still written in C, so now let's write an OC review02.m.

1 /**2 #import role 1: Copy the contents of the right file 2: can automatically prevent the contents of the file is repeated copy3  */4 #import<Foundation/Foundation.h>5 6 intMainintargcConst Char*argv[]) {7 @autoreleasepool {8         //Insert code here ...9NSLog (@"Hello, Real OC!");Ten     } One     return 0; A}

Error when executing cc REVIEW02.O command

Do you know what it is? Because our OC program introduces the foundation framework and therefore requires a compiler when linking, the framework I use is the foundation

CC Review02.o-framework Foundation

It's going to be all right, huh?

OC Basics Review 01-First OC Program

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.