Interview question 2

Source: Internet
Author: User

I only record some of the answers that are more informative and will be improved later. I hope you can give me some wonderful answers. Thank you!

1: What is the size-end mode? Use the macro-real-size-end mode to read and write data.

See http://blog.csdn.net/ce123/article/details/6971544

2: Compare the advantages and disadvantages of the for loop in the following two modes, and how to optimize

 
For (I = 0; I <n; I ++) {If (condition) dosomething (); elsedootherthing ();}

Advantage: simple and easy to understand

Disadvantages: each cycle should be a if judgment, so compared to the following method at least more N-1 if judgment, and if judgment interrupted the for loop pipeline operation, low efficiency

 
If (condition) {for (I = 0; I <n; I ++) dosomething () ;}else {for (I = 0; I <n; I ++) dootherthing ();}

Disadvantages: complicated writing and hard to read

Advantage: higher efficiency than above

3:CodeAre there any errors or results?

 
# Define Max 255 unsign char a [Max], I; for (I = 0; I <Max; I ++) A [I] = I;

4: The use of sizeof, specifically what do not remember, but the main test is sizeof pointer and array evaluate

5: Implement strcmp library functions by yourself

During the interview, I wrote one by myself and thought it was okay (if the two strings used for comparison do not end with '\ 0 ',Program):

 
Int strcmp (const char * str1, const char * str2) {While (str1 & str2 & (* str1 ++ = * str2 ++ )); return (* str1)-(* str2 );}

After reading the definition of this function in window, I feel a little complicated. I don't know any bugs above. Please refer to me for correction.

6. Use WinSock to implement a simple client server program

For a person who has never been taller than window C, this is really not. I only know that socket is enough. I believe it should be very simple for those who are engaged in windows.

7: Write the if statement for bool, float, and pointer comparison with "zero value ".

Reference: http://blog.csdn.net/jhg1204/article/details/8980186

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.