GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Sep-2005, 05:26
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Post

Re: Command Line Arguments, Part 2


I just posted a GID Community blog entitled: Command Line Arguments, Part 2.

Quote:
Single Characters as Command Line Parameters

A single character as a parameter, although not extremely useful, will give us a basis for later in this topic. read more...

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  
Old 17-Feb-2006, 11:27
davis
 
Posts: n/a

Re: Command Line Arguments, Part 2


Quote:
Originally Posted by WaltP
I just posted a GID Community blog entitled: Command Line Arguments, Part 2.



Please let me know what you think.


The topic basis is a good one, but there are probably enough convincing arguments to suggest that for every switch statement, that there should also be a default case, which seems to be missing in your code examples.

Just a thought that you might like to add a default case. In the example of command line argument processing, it is entirely likely that someone could easily enter something that wasn't handled by your case statements and therefore would be handled properly with a default case...


:davis:
  #3  
Old 17-Feb-2006, 12:30
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: Command Line Arguments, Part 2


Quote:
Originally Posted by davis
The topic basis is a good one, but there are probably enough convincing arguments to suggest that for every switch statement, that there should also be a default case, which seems to be missing in your code examples.

Just a thought that you might like to add a default case. In the example of command line argument processing, it is entirely likely that someone could easily enter something that wasn't handled by your case statements and therefore would be handled properly with a default case...


:davis:
Good point, that was certainly a mistake.

Without the default case in the first example, a single invalid letter would be ignored as would any second or further letter in the parameter. Not a big problem in this example, but worth pointing out for a more critical project.

In the second example, an illegal character was silently ignored and could bunge up the calculation. A definite error.

Thanks for pointing that out.
__________________

Age is unimportant -- except in cheese
  #4  
Old 25-Feb-2006, 01:14
TreyAU21's Avatar
TreyAU21 TreyAU21 is offline
Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 116
TreyAU21 has a spectacular aura aboutTreyAU21 has a spectacular aura about

Re: Command Line Arguments, Part 2


That was a nice little tutorial. One thing that you might want to challenge the reader to do at the end (with the calculator example). Is to alter the code to handle preorder and postorder operations such as '2 3 +' or '/ 8 2' instead of assuming that the first num passed with always be the first operand.
__________________
If practice makes perfect and nobody's perfect... why practice?

Homepage: http://www.treywhite.com
Blog: http://www.treywhite.com/blog.php
Web Design Company: http://www.ewebproductions.com
 
 

Recent GIDBlogObservations of Iraq by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Beginning Python Tutorial (Part 3) crystalattice Python Forum 0 16-Aug-2005 02:51
[Tutorial] Pointers in C (Part II) Stack Overflow C Programming Language 0 27-Apr-2005 17:36
help with arguments to main krepunk C++ Forum 1 16-Mar-2005 12:44
main() arguments crystalattice C Programming Language 2 24-Oct-2004 00:05
Re: Command Line Arguments, Part 1 WaltP C Programming Language 0 10-Jul-2004 23:34

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:05.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.