Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

C++ integers and words


ghost's Avatar
0 0

is there any way to make an integer eqaul to a word like if you were doing a
simple if function program if you entered Kkae it would be eqaul to something like 87. is it possible?


lukem_95's Avatar
Member
0 0

you could use #define kkae 87 (or whatever you said)

e.g.

#include <iostream> //As its c++

#define lukem 1337 //0mgz 1337 h4x0r

using namespace std;

int main(int argc, char *argv[])
{
char word[];
cin >> word;
if(word == lukem){
word = lukem; //make word equal to 1337
} else {
cout << "You suck!";
}

cin.get()
return 0;
}

ghost's Avatar
0 0

Yup… just fix all the crippling errors in that code and it'd work fine :P (No offence Lukem)


ghost's Avatar
0 0

lukem_95 wrote: you could use #define kkae 87 (or whatever you said)

thanx and i will fix all the crippling errors


lukem_95's Avatar
Member
0 0

lol none taken, im pretty good at c, but i wrote that off the top of my head, and it was totally theoretical, never needed something like that before.

btw, i use c, not c++ so that may also account for some of it.


ghost's Avatar
0 0

stack v heap ^

shell code


ghost's Avatar
0 0

If you know enumerations you could always use that but you would have to sort of reverse the process.