I have the following code:
#include <iostream>
using namespace std;
int main () {
char alphabet[]="abcdefghijklmnopqrstuvwxyz";
char word;
cout <<"Please input a word: " <<endl;
cin >> word;
int res = -1;
for (int i = 0; alphabet != '\0'; i++)
{
if (alphabet == word)
{
res = i;
}
}
if (res != -1)
{
cout << word << " has the number " << res << " in the array \n";
}
}
//Thanx to dave sinkula and zyruz for their help so far
What i want to do is to input a word and get as output a number - the problem is that i dont know how to assign my own values (numbers) to the char array. For instance i dont want a to be 0, b to be 1 etc - i want a to be 17, b to be 23 and so on - what i want to do is to assign to each letter my own value.
Any suggestions?