More nubiness

Thread Solved

Join Date: Jul 2008
Posts: 181
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 2
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

More nubiness

 
0
  #1
Nov 11th, 2008
When switch"ing" (....)

If the user inputs 1, would you just use

case 1: or case '1':

thnks
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 421
Reputation: JoBe is on a distinguished road 
Solved Threads: 4
JoBe's Avatar
JoBe JoBe is offline Offline
Posting Pro in Training

Re: More nubiness

 
0
  #2
Nov 11th, 2008
1 is a number.

'1' is a character.

So, it depends on which of the two you are going to use.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 181
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 2
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Re: More nubiness

 
0
  #3
Nov 11th, 2008
Thanks a lot Jobe, here is my code i am currently working on as of about 10 minutes ago.

  1. #include <iostream>
  2. #include <fstream>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. //SetConsoleTitle("ItemIzer");
  8.  
  9. int main()
  10. {
  11. char cho
  12.  
  13. cout<<"\n\n\n\n\t\t";
  14. cout<<"1: View Catagory";
  15. cout<<"2: Append new item";
  16. cout<<"3: Truncate an item";
  17. cout<<"4: Create Catagory";
  18. cout<<"5: Delete Catagory";
  19.  
  20. do
  21. {
  22. bool repeat(false);
  23. cout<<">>";
  24. cin>>cho;
  25.  
  26. switch (cho)
  27. {
  28. case 1:
  29. case 2:
  30. case 3:
  31. case 4:
  32. void name;
  33. ofstream Clist ("Catagorylist.txt", app);
  34. cin>>name;
  35. Clist<<name;
  36. case 5:

Would everything in there be legal so far as long as i finishing declaring everything? Thanks
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1,821
Reputation: vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold 
Solved Threads: 213
vmanes's Avatar
vmanes vmanes is offline Offline
Posting Virtuoso

Re: More nubiness

 
0
  #4
Nov 11th, 2008
Since your switch variable cho is a char, your case labels must be like case '1': - the labels must be literal characters.
Don't own a gun but I'm going to join the NRA.
I figure anything that irritates liberals is worth my support.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 421
Reputation: JoBe is on a distinguished road 
Solved Threads: 4
JoBe's Avatar
JoBe JoBe is offline Offline
Posting Pro in Training

Re: More nubiness

 
0
  #5
Nov 11th, 2008
- char cho ;

- After each case you have to use a break; , otherwise, the program will fall threw to each case that is presented.

- I guess you haven't shown all the code, seeing as you didn't use close braces for the do loop and main.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 181
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 2
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Re: More nubiness

 
0
  #6
Nov 11th, 2008
Yes i understand i need to use break; =P

So what if i make cho an integer? Then it would be 1 and not '1' correct?

>> - the labels must be literal characters.

I got a long way to go lol. Thanks in advance
Last edited by clutchkiller; Nov 11th, 2008 at 3:20 am.
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 421
Reputation: JoBe is on a distinguished road 
Solved Threads: 4
JoBe's Avatar
JoBe JoBe is offline Offline
Posting Pro in Training

Re: More nubiness

 
0
  #7
Nov 11th, 2008
Originally Posted by clutchkiller View Post
Yes i understand i need to use break; =P

So what if i make cho an integer? Then it would be 1 and not '1' correct?

>> - the labels must be literal characters.

I got a long way to go lol. Thanks in advance
Yep, like vmanes mentioned !
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 181
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 2
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Re: More nubiness

 
0
  #8
Nov 11th, 2008
thanks guys!
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 521 | Replies: 7
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC