![]() |
|
#1
|
||||
|
||||
Re: Things to Avoid in C/C++ -- gets() , Part 1I just posted a GID Community blog entitled: Things to Avoid in C/C++ -- gets() , Part 1.
Quote:
Please let me know what you think. This is an auto-generated message posted by GIDNetwork™ on behalf of the author. __________________
Age is unimportant -- except in cheese |
|
#2
|
||||
|
||||
void main();Things to avoid in C/C++
void main() main() is an integer function, and should be specified as such. Now I can get into long-winded explanation of why, but it's already been done, with examples. I first turn your attentopn to this article by Steve Summit: http://www.eskimo.com/~scs/readings/...in.960823.html. He explains what could happen and why. How the improper form started and why it's been allowed to continue. The second is http://users.aber.ac.uk/auj/voidmain.shtml by Alun Jones, with a real world example of an error. Another good explanation is at http://home.att.net/~jackklein/ctips01.html#int_main. So the bottom line is void main() 1) is wrong according to the standards. 2) is not guaranteed to work properly. 3) may cause problems for the operating system. Last edited by WaltP : 09-Dec-2004 at 22:40.
|
|
#3
|
|||
|
|||
Re: Things to Avoid in C/C++ -- gets() , Part 1Hi,
In your blog: GIDNetwork > Things to Avoid in C/C++ -- gets() , Part 1 there is the following example: Quote:
Also if "fgets(b2, 5, stdin); // 5 is the size of buffer b2" we cannot catenate the dummy to the b2. Rather in the spirit of the article I understood that we just want to clean the input stream by reading to dummy and that's all. "dummy" just acts as trash bin. |
|
#4
|
||||
|
||||
Re: Things to Avoid in C/C++ -- gets() , Part 1If you read the description carefully, is says
Quote:
CPP / C++ / C Code:
Of course, you could just leave the buffer as you suggest, it's just not what was designed. __________________
Age is unimportant -- except in cheese |
|
#5
|
|||
|
|||
Re: void main();Quote:
|
|
#6
|
|||
|
|||
Re: void main();Quote:
|
Recent GIDBlog
Toyota - 2008 September Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Floating point exception error (Note-long post) | crystalattice | C++ Forum | 16 | 11-Sep-2004 07:37 |
| Vilitas Merger - any problems? | nickbeee | Web Hosting Forum | 13 | 09-Sep-2004 05:04 |
| Some small things | Allowee | GIDSearch™ | 6 | 14-Jul-2004 01:40 |
| A Comprehensive Digest of C++ | mithunjacob | C++ Forum | 39 | 20-Jun-2004 19:09 |
| Creating a search engine friendly forum | BobbyDouglas | Search Engine Optimization Forum | 14 | 20-Nov-2003 16:31 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The