Helpc++ help please?

Posts 1–6 of 6 · Page 1 of 1
c++ help please?
my problem is system dose not like virables.. even tho i have command as char it dose not regester what iv typed iv used string system dose not like that heres the code.
Code:
#include "iostream"
#include "windows.h"
#include "string"
using namespace std;

char command;
int num ;



while ( num == 1) {
		num = 0;
		cout << "Welcome what comand do you want to run? \n";
		cin >> command ;
		Sleep(50);
		cout << "your command was \n " << command;
		system( "color 4" + command );
		system("pause");
		return 0;
	}
there is int main but that bit is not important it works
sorted thanks to all :P

thanks Josh
Quote Originally Posted by jc_234 View Post
my problem is system dose not like virables.. even tho i have command as char it dose not regester what iv typed iv used string system dose not like that heres the code.
Code:
#include "iostream"
#include "windows.h"
#include "string"
using namespace std;

char command;
int num ;



while ( num == 1) {
		num = 0;
		cout << "Welcome what comand do you want to run? \n";
		cin >> command ;
		Sleep(50);
		cout << "your command was \n " << command;
		system( "color 4" + command );
		system("pause");
		return 0;
	}
there is int main but that bit is not important it works
sorted thanks to all :P

thanks Josh
You really need to start looking at pages that talk about c++ best practices. Because this is just filled with bad bad coding.
Quote Originally Posted by Sammy View Post
You really need to start looking at pages that talk about c++ best practices. Because this is just filled with bad bad coding.
it is sorterd... well i re-done the code and i know my code is bad because im just starting out but I am looking at ways other people code. and starting to use comments aka // and thanks you sir sam
Quote Originally Posted by jc_234 View Post
it is sorterd... well i re-done the code and i know my code is bad because im just starting out but I am looking at ways other people code. and starting to use comments aka // and thanks you sir sam
It's better to start the right way, than first learning wrong and later changing bad habits.
start watching some tutorial, ask help to programming forums
I don't know exactly what you wanted to do, but I fixed the code's problems. Here you go.

Code:
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;

char command;
int num;

int main()
{
	string command;
	cout << "Welcome what comand do you want to run?" << endl;
	cout << "Command: ";
	cin >> command;
	Sleep(500);
	cout << "your command was " << command << "." << endl;
	system("pause");
	return 0;
}
I don't know where you started learning C++, but don't go there anymore.
Hope this helped, I don't know.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?