![]() |
| | #1 |
| Registered User Join Date: Nov 2009
Posts: 3
| Strings and if Code: int main() {
char answer [50];
char ans1;
printf("Work out?\n");
scanf("%s", answer);
if (answer=='Pressure') {
printf("worked");
}
else {
printf("nope");
}
Would be grateful if anyone could spare some in-sight |
| Xandan is offline | |
| | #2 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,461
| Use strcmp and compare to 0. Also, single quotes means one character, and double quotes means a string. So, 'a' = a char, "a" = a string (char*). Also, read up on Scanf woes.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is online now | |
![]() |
| Thread Tools | |
| Display Modes | |
|