954,135 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

practice(newbie)

Hello guys,
This code returns 2 errors and I dont understand why.

#include <iostream>
#include <string>
using namespace std;

char choice;
void M();
void C();
void Process();

void M(){
	cout <<"Multiplication\n";
}
void C(){
	cout << "Calculation\n";
}
void Process(){
	cout << "Make a choice\n"
		<< "C or M only\n";
	cin >> choice;
	while (strcmp(choice, "M")!=0) || (strcmp(choice, "C")!=0){
		cout << "ERROR Enter again";
	cin >> choice;
	
	}
	return;
}


void main () {
	Process();
	while (strcmp(choice, "M") == 0){
		M();
	}
	return;
	while (strcmp(choice, "C") == 0){
		C();
		return ;
	}
	
}


Any idea? thanks

MaxC
Newbie Poster
11 posts since May 2004
Reputation Points: 12
Solved Threads: 0
 

Oh... I got it. I'm using strcmp to compare a char variable. :)

MaxC
Newbie Poster
11 posts since May 2004
Reputation Points: 12
Solved Threads: 0
 

Good, well next time try doing the checking first Ok

FireNet
Posting Whiz in Training
258 posts since May 2004
Reputation Points: 108
Solved Threads: 7
 

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

abu_sager
Newbie Poster
10 posts since Jun 2004
Reputation Points: 12
Solved Threads: 2
 
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?
:!:

FireNet
Posting Whiz in Training
258 posts since May 2004
Reputation Points: 108
Solved Threads: 7
 

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

kc0arf
Posting Virtuoso
Team Colleague
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You