Pointer art Reading Notes

Source: Internet
Author: User

Collation  

  Hope that you can give pointers to the brightest stars in the sky (*)

Online drive download: micro drive file format: xmind production software: Connotation of xmind pro pointer
The pointer variable is used to store the variable address. Since we use * to act on Pointer variables, the author prefers to treat pointers as stars. The author compares the pointer to a key (the key of the mailbox) and regards the variable value as a letter.
The name of the connotation array indicates the address of the first element of the array. Because the array variable stores the address of the first element, the array variable is also a pointer variable. However, the difference is that you cannot perform auto-increment (++) or auto-increment (--) operations on the array variables. Therefore, the array variables are called Pointer constant . We can use [] or * to obtain the pointer to the value in the variable. Pointers (*) and arrays ([]) are interconnected. String Common Operations> String Length: strlen (str1); string replication: strcpy (str1 receiver, str2 receiver) strncpy (str1 receiver, str2 receiver, N replica count) string connection: strcat (DEST connector, source connector) strncat (DEST, source, n) string comparison: strcmp (str1, str2) str1 = str2 address comparison, used to determine whether str1 and str2 point to the same variable. The struct uses a pointer to access a member (*).
Struct is a derived data type. Struct is a collection composed of the same or different data types.
Common Code Define struct
 
TypedefStruct_ Student {CharName [10];IntScore;} student;

Allocate memory

 
Student * PTR = (student *) malloc (Sizeof(Student ));

 

File Operations

 Int  Main (){  Char Id [ 10 ]; File * Fptr;  If (Fptr = fopen ( "  Test. dat  " , "  A +  " ) = Null) {printf (  "  Unable to open test. dat  "  );  Return   1 ;}  Do  {Printf (  "  Enter ID \ n  "  ); Scanf (  "  % S  "  , ID); fprintf (fptr,  "  % S \ n  "  , ID );}  While (Strcmp (ID,"  -1  " )! = 0  ); Fclose (fptr );  Return   0  ;} 

 

Book errors

1. Section 4th (page 11) describes the struct in this way (see ). -- In fact, the struct is composed of the same or different data types.

2. (page 12) Is it an error I understand? From this sentence, I mistakenly believe that the struct members are adjacent in the memory. -- But not actually.

3. Page 53 (command line independent variables), which clearly indicates different meanings. How can we generalize them together?

 

Recommendation  

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.