hi, when i add something to the code there are some error, can someone please let me know or if possbile please correct it for me by letting me know as i want to know what is wrong with the code....
when i run it the output is 66 62 12 15 28a s string, when i input Johnny.
my target is to convert those number of string to characters as i assign A is 00, B is 01....till.......Z is 26. if the number >= 26, for example 44 is larger so 44%26 = 18 so the character output will be S.
here is the code
Code:
stringstream numbers;
/* Insert integer into stringstream*/
numbers <<numLowerCaseLetter(name)<<sumAscii(name)<<lastValue<<counter<<sum;
/* Convert stringstream into string.*/
string str = numbers.str();
if(str.size() % 2 == 0)
{
for(int i = 0; i < str[i]; i=i+2)
{
numOfTwo[i]=str.substr(i,2);
cout<<numOfTwo[i]<<" ";
}
}
else
{
str.size()+1;
str.append( 1, '0' );
for(int i = 0; i < str[i]; i=i+2)
{
numOfTwo[i]=str.substr(i,2);
cout<<numOfTwo[i]<<" ";
}
}
// Final solution which convert number into character by producing a code.
for(int i = 0; numOfTwo[i]; i++)
{
if(numOfTwo[i] >= 26)
{
modLeft = numOfTwo % 26;
cout<< something[modLeft];
}
else
{
cout<<something[numOfTwo[i]];
}
when i run the code, this error comes out
In function `int main()':
could not convert `numOfTwo[i]' to `bool'
no match for 'operator>=' in 'numOfTwo[i] >= 26'
invalid operands of types `std::string[15]' and `int' to binary `operator%'
no match for 'operator[]' in 'something[numOfTwo[i]]'
syntax error before `{' token