Summary of the interview process (I). Summary of the interview process

Source: Internet
Author: User

Summary of the interview process (I). Summary of the interview process

Since I started my job in the previous job, I have been visiting the blog park in my spare time. Many articles in the blog garden play a very important role in my daily work.

I used to want to write something, but I never knew what to write. I just resigned some time ago and recorded some of the questions I encountered during the interview. I thought it was a basic review.

 

Use the file operation function in the c standard, and output all the data to the terminal in a hexadecimal format after reading the data (this is the question of the written examination in the interview today ), I wrote the following based on my own understanding. If it is inappropriate, I would like to criticize and correct it.

  

1 # include <stdio. h> 2 # include <stdlib. h> 3 # include <string. h> 4 5 // use the file operation function in the c standard. After reading all the functions, output them to the terminal 6 7 int main (int argc, char * argv []) in hexadecimal format. 8 {9 FILE * fp = fopen ("sizeofSTRUCT. cpp "," r "); 10 if (NULL = fp) 11 {12 printf (" % s \ n "," fopen () ERROR !!! "); 13 return-1; 14} 15 16 long curPos, longth; 17 // get the initial position of the file pointer 18 curPos = ftell (fp ); 19 20 // obtain the file size so that the memory is applied for later. // After fseek (), the file pointer will be at the specified position. After this execution, the file pointer will be at the end of 22 fseek (fp, 0, SEEK_END); 23 longth = ftell (fp); 24 25 // place the file pointer at the beginning of the file for subsequent reading of the file content 26 fseek (fp, 0, SEEK_SET ); 27 28 char * buff = (char *) malloc (longth + 1); 29 memset (buff, 0, longth + 1 ); 30 31 // output file content in string format 32 fread (buff, longth, 1, fp); 33 printf ("% s \ n", buff ); 34 35 // output 36 int I = 0 in hexadecimal format; 37 for (; I <longth + 1; ++ I) 38 printf ("% x ", (buff + I); 39 40 printf ("\ n"); 41 42 free (buff); 43 buff = NULL; 44 45 return 0; 46}
 

 

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.