OBJECT-C 1.0 Chapter III: Object-Oriented Programming fundamentals (OOP)

Source: Internet
Author: User

1. Indirect (indirection)
1.1 Variables and indirection (use variables to replace some numbers)
1.2 Indirect use of file names
const indicates that a variable is not allowed to be changed
const int Nvalue;//nvalue is const
const char *pcontent; *pcontent is const, pcontent variable
const char* Const pcontent; Pcontent and *pcontent are both const.
Strlen (String value); Returns the length of the value string
As the following example, can be written by non-professional files, which is indirect, but the path is the decision path, not too ideal
FILE *worldfile = fopen ("/tmp/words.txt", "R"); Open the file and read the contents of the file, where TMP is the UNIX temp directory
Char word[100];
while (fgets (Word, wordfile)) {//fgets () reads a line of text from a file and places it in Word
Word[strlen[word]-1] = ' + '; The fgets () call retains a newline character that separates each line, and we don't need to, if we leave him, add a char, so instead
NSLog (@ "%s is%d characters long", Word,strlen (word)); Printing information
Fclose (Wordfile); Close File

OBJECT-C 1.0 Chapter III: Object-Oriented Programming fundamentals (OOP)

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.