there is a intrinsic function, ichar(C), to convert character to a numerical value (ASCII?) in FORTRAN. Can any one tell me a similar function in C++?

Recommended Answers

All 2 Replies

You don't need a function for that. Example:

char ch = 'a';
int i = ch;
cout << "Char " << ch << "  = ASCII: " << i << endl;

Regards Niek

C and C++ languages really don't have a character data type -- char is readlly just a one-byte integer. Characters such as 'a', 'b', etc can be represented in char, int, or long because internally they are just integers and have an integer value. What you see as on the screen or on paper is just the representation of the letter and depends on the font that is used to print it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.