What I want is when I type "calc;" (without quotes), The calculator opens. Else, if I didn't type it correctly (example: "calc" (without quotes)) it will generate an error.

#include <iostream>
#include <string>

using namespace std;

int main () 
{
	string calc;
	char end;
	end = ';';

	cin >> calc >> end;

	if(calc == "calc") 
	{
		system("calc");
	} 
	else 
	{
		cout << "Error..." << endl;
	}
	return 0;
}

Line 12.

Why are you doing this

cin >> calc >> end;

Why >> end;

Is this what your trying to accomplish?

#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main () 
{
	string calc;

	cin >> calc;

	if(calc == "calc") 
	{
		system("calc");
	} 
	else 
	{
		cout << "Error..." << endl;
	}
	return 0;
}

you forgot the ';' in:

...
//HERE - > calc == "calc;"
	if(calc == "calc") 
	{
		system("calc");
	} 
	else 
	{
	...

and also you have to include the <stdlib.h> header. without it you can't use "system"

Thanks, works perfectly!

But the main purpose of the 'end' was a ending character ';' not endl which ends the line. But this works as well, thanks to both of you! Any reputation system or award?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.