943,341 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 3340
  • C++ RSS
May 27th, 2004
1

practice(newbie)

Expand Post »
Hello guys,
This code returns 2 errors and I dont understand why.
C++ Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 12
Solved Threads: 0
Newbie Poster
MaxC is offline Offline
11 posts
since May 2004
May 27th, 2004
0

Re: practice(newbie)

Oh... I got it. I'm using strcmp to compare a char variable.
Reputation Points: 12
Solved Threads: 0
Newbie Poster
MaxC is offline Offline
11 posts
since May 2004
May 27th, 2004
0

Re: practice(newbie)

Good, well next time try doing the checking first Ok
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004
Jun 7th, 2004
1

Re: practice(newbie)

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
Reputation Points: 12
Solved Threads: 2
Newbie Poster
abu_sager is offline Offline
10 posts
since Jun 2004
Jun 11th, 2004
0

Re: practice(newbie)

Quote 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?
:!:
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004
Jun 11th, 2004
0

Re: practice(newbie)

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
Team Colleague
Reputation Points: 121
Solved Threads: 57
Posting Virtuoso
kc0arf is offline Offline
1,629 posts
since Mar 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C++ Forum Timeline: Parse error, syntax error, Forbids declaration
Next Thread in C++ Forum Timeline: switch/case statement





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC