P
PentiumPunk
Hey, I am trying to get a character, check its ascii value, if the ascii is
less than 100 then I append a 0 on the front of it, so it will have 3
digits. That is my aim to have a 3 digit integer to add to my hash table
that corresponds to the ascii of a letter.
i tried:
char ch;
int i, j;
string s, s2;
fin>>str; //input string from file
for(i=0;i<str.size();i++)
{
ch=str;
if(ch<100)
{ j=ch; // assigns ascii number to j
s=j;
s2="0"+s;
cout<<s2;
}
}
it just outputs 0b ("bird" is the word that is input. and since b's ascii is
98, its supposed to output 098 ). how can i fix this? Thanks in advance!
~PentiumPunk~
less than 100 then I append a 0 on the front of it, so it will have 3
digits. That is my aim to have a 3 digit integer to add to my hash table
that corresponds to the ascii of a letter.
i tried:
char ch;
int i, j;
string s, s2;
fin>>str; //input string from file
for(i=0;i<str.size();i++)
{
ch=str;
if(ch<100)
{ j=ch; // assigns ascii number to j
s=j;
s2="0"+s;
cout<<s2;
}
}
it just outputs 0b ("bird" is the word that is input. and since b's ascii is
98, its supposed to output 098 ). how can i fix this? Thanks in advance!
~PentiumPunk~