Im trying to do something if command[j]==' however the below code doesnt work
if(''' == command[j])
Printable View
Im trying to do something if command[j]==' however the below code doesnt work
if(''' == command[j])
lose the quotes:
That what u mean?Code:if (something == command[j])
{
...
}
uh i dunno everything else ive been doing has been like this:
Code:if('z' == command[j])
{
cout<<"26";
}
Without the spaces.Code:if (command[j] == ' \ '')
// do something
What data types are you using char arrays or the string class?
You cannot test char arrays like this. You need a 2D char array and strcmp.Code:#include <iostream>
#include <string>
using namespace std;
int main()
{
string s2[] = { "test", "testing", "tested" };
for(int i=0; i < 3; i++)
if("test" == s2[i])
cout << "26" << endl;
else
cout << s2[i] << endl;
return 0;
}
This man is correct. Disregard everyone else's replies.Quote:
Originally posted by slaveofthenet
Without the spaces.Code:if (command[j] == ' \ '')
// do something