User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 429,867 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,445 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums

error checking of user input

Join Date: Sep 2004
Posts: 6,355
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 29
Solved Threads: 466
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: error checking of user input

  #5  
Apr 16th, 2005
>not equal to NULL
'\0' and NULL should not be mixed. If you do so it makes your code harder to follow. '\0' is the null character and should only be used in character context, and NULL is the null pointer and should only be used in pointer context.

>if(player_name != '\0')
If you're checking to see if the input is numeric then this doesn't do what you think it does. It checks pointer_name to see if it's a null pointer. However, if it were a null pointer, the program would have crashed here:
cin.getline(player_name, 50);
You've replaced one broken construct that doesn't do what you want with another broken construct that doesn't do what you want.
I'm a programmer. My attitude starts with arrogance, holds steady at condescension, and ends with hostility. Get used to it.
Reply With Quote  
All times are GMT -4. The time now is 7:40 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC