I'm trying to write the Caesar Cipher program, but I keep getting the error message in the 1st picture. enter image description here

So I tried to write a simple program that would prompt the user for input and the print out the ASCII value of the 1st character, but it keeps printing out the same number (see below). enter image description here

Can someone please tell me where my mistake is? Thanks!

  • Please post code instead of Pictures. Your first Picture does not Shows the complete code because the error is at line 31 and that we cannot see.
    – Wafeeq
    Jun 14 '16 at 8:37

Int the second picture, First, you're printing the string length of the string input by user. Second, to print the integer value of a char, don't do this:

int x = 's[0]'

The quotes shouldn't be there. just do this:

int x =  s[0]

the value of x is now a char value of the 0th character in the string S That's why you're getting that long number output.


In your first Picture, remove the signle quotes ' from which is probably at line number 31,

int u_letter = `plaintxt[i]`;

If you put ', your are trying to pass a character not the value of plaintxt at i index.

In your second Picture, you also did the same mistake.

For Example:

string e = 'abc';


char a = 'e[0]';

now a does not have first letter of string e but 'e[0]' itself. If you want to pass the value

 char a = e[0]; // without quotes you can acccess the value at index 0.  

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .