Garbage "How programs are made" -- Chapter A (1) of C programming partner)

Source: Internet
Author: User
[Sample]

 

 

[Evaluation]

The title clearly missed two characters-"junk", which should be 'How the spam program is developed '.
There are still some unclear issues, and some necessary prerequisites are not explained. For example, the maximum length of a keyword. If there is no limit on the length of the keyword, the code will be completely different.
Note that the problem requires "output these file names to the screen and result files in ascending order ".

[Sample]

 

 

[Evaluation]

Both 128 and 1024*128 are unknown magicnumbers. 128 as the length of the file name may still be reasonable, 1024*128 is definitely a "Flying Fairy. It is estimated that the author was holding his teeth and holding his teeth.
The design of the txtfile structure is also inexplicable. Why do we need to get such a large array for calculating word frequency? Think twice about it. Later I guessed that the author's intention was to read the file into the array and then count the word frequency. This idea is really amazing. Count the number of words in an article, and remember to memorize the article first. Kindergarten Children won't come up with a way to be so mentally retarded, right?

[Sample]

 

 

[Evaluation]

Sure enough, I really read the file content into the array.
It seems that it is not difficult for a person to be stupid, but it is difficult to implement stupid ideas to the end. More difficult than this? It is the courage to print such stupidity in books to cheat the children who do not understand things. However, none of these are the most difficult. The most difficult thing is to dare to describe the stupidity of cheating on children in books as "practice, this allows you to develop good and industry-standard programming habits and ideas and lay the necessary foundation for your future development ~ 2 ). TMD has dug a deep hole in people's lives. It is also a "Foundation" to help people ". This "Basic" is playing too deep, and it's time to go below sea level.
Even if we leave this silly idea behind, we can only look at it from the code perspective, and this function is also full of loopholes.
First

// Check the parameter validity if (null = file) return;

When the parameter is invalid, the function returns the same result as when the parameter is legal. So what is the significance of this "parameter validity check? Isn't it a pair of deaf ears? This is like sending a person to check for fire hazards. This person finds a fire hazard, but does not give a warning. Therefore, from this perspective, the "parameter validity check" here is a form of virtual installation, and will inevitably be put to war in any case.
Similarly, when FP is null, that is, when the file fails to be opened, this function is quietly returned like everything else. In this way, if (null! = FP) It's just as funny as the monkey salute in the circus: although it looks a lot like that, it doesn't actually have a polite meaning. It's nothing more than a gesture of pretending to be effective.

[Sample]

 

 

[Evaluation]

This Code is even more funny. filecount and files are two irrelevant data objects,
For (INT I = 0; I <filecuont; I ++)
In, the Code author makes a mess with the limit spectrum and describes filecount as the size of files. However, files actually have their own size, that is, sizeof files/sizeof files [0]. Therefore, this code is just as absurd as it is to install a prosthetic hand on a dog with sound limbs.

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.