converting inputted character to its integer code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<iostream>
using namespacestd;

void readonechar(char)

int main(){
char ch;
cout<<"enter a character";
cin ch;
readonechar(ch);
return 0;
}

void readonechar(char x)
{
????
}


Please help me, i'm stressing out on c plus plus, too much bloody things i dont know, and i got exams coming up soon.. W@#$W
bump
¿What do you want to do?

Please be more patient.
I want to create a function so that , everytime i pass a value through it, it will convert the value to its integer code
A character already is its integer code. All you have to do is cast it so it prints correctly:

1
2
3
4
char ch = 'a';

cout << ch;  // prints 'a'
cout << (int)ch;  // prints '97' (the ASCII code for 'a') 
Topic archived. No new replies allowed.