practice(newbie)

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2004
Posts: 11
Reputation: MaxC is an unknown quantity at this point 
Solved Threads: 0
MaxC MaxC is offline Offline
Newbie Poster

practice(newbie)

 
1
  #1
May 27th, 2004
Hello guys,
This code returns 2 errors and I dont understand why.
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. char choice;
  6. void M();
  7. void C();
  8. void Process();
  9.  
  10. void M(){
  11. cout <<"Multiplication\n";
  12. }
  13. void C(){
  14. cout << "Calculation\n";
  15. }
  16. void Process(){
  17. cout << "Make a choice\n"
  18. << "C or M only\n";
  19. cin >> choice;
  20. while (strcmp(choice, "M")!=0) || (strcmp(choice, "C")!=0){
  21. cout << "ERROR Enter again";
  22. cin >> choice;
  23.  
  24. }
  25. return;
  26. }
  27.  
  28.  
  29. void main () {
  30. Process();
  31. while (strcmp(choice, "M") == 0){
  32. M();
  33. }
  34. return;
  35. while (strcmp(choice, "C") == 0){
  36. C();
  37. return ;
  38. }
  39.  
  40. }

Any idea? thanks
MSVC++
Quick reply to this message  
Join Date: May 2004
Posts: 11
Reputation: MaxC is an unknown quantity at this point 
Solved Threads: 0
MaxC MaxC is offline Offline
Newbie Poster

Re: practice(newbie)

 
0
  #2
May 27th, 2004
Oh... I got it. I'm using strcmp to compare a char variable.
MSVC++
Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: practice(newbie)

 
0
  #3
May 27th, 2004
Good, well next time try doing the checking first Ok
See what you can, remember what you need

Fourzon | Earn via Coding
Quick reply to this message  
Join Date: Jun 2004
Posts: 10
Reputation: abu_sager is an unknown quantity at this point 
Solved Threads: 2
abu_sager abu_sager is offline Offline
Newbie Poster

Re: practice(newbie)

 
1
  #4
Jun 7th, 2004
Hello my poor c++ programmers
strcmp take two argument of type char * i.e array of character not char
i.e you can compare between
char *p = "SADDAM",l= "BOOSH";
cout << strcmp(p,l);
i hope you understand this thing
Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: practice(newbie)

 
0
  #5
Jun 11th, 2004
Originally Posted by abu_sager
Hello my poor c++ programmers
strcmp take two argument of type char * i.e array of character not char
i.e you can compare between
char *p = "SADDAM",l= "BOOSH";
cout << strcmp(p,l);
i hope you understand this thing
What makes you so rich abu_sager?
:!:
See what you can, remember what you need

Fourzon | Earn via Coding
Quick reply to this message  
Join Date: Mar 2004
Posts: 1,620
Reputation: kc0arf is a jewel in the rough kc0arf is a jewel in the rough kc0arf is a jewel in the rough 
Solved Threads: 51
Team Colleague
kc0arf kc0arf is offline Offline
Posting Virtuoso

Re: practice(newbie)

 
0
  #6
Jun 11th, 2004
Abu & FireNet,

Let's keep the discussion Technical, and leave the other stuff off the boards please. That is what we are here for. Let's choose our wording better next time.

Christian
Quick reply to this message  
Closed Thread

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



Similar Threads
Other Threads in the C++ Forum


Views: 2977 | Replies: 5
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC