Need Help Regarding converting String to ASCII value
hello everyone,
Could you please help me out as how to convert string to ascii value.
thanks,
riya
Re: Need Help Regarding converting String to ASCII value
A simple google search gives me the ans. See here
And post post non-vc++ related query to this forum.
Re: Need Help Regarding converting String to ASCII value
@hypheni:thanks for the reply...i tried that but am getting error that says:-
#error C2440: 'type cast' : cannot convert from 'class CString' to 'int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
thanks,
neha
Re: Need Help Regarding converting String to ASCII value
Code:
#include <string>
#include <iostream>
using namespace std;
int main () {
string s = "Hello";
cout << int(s[0]);
return 0;
}
Does that work for you?
Re: Need Help Regarding converting String to ASCII value
Quote:
Originally Posted by
riya123
@hypheni:thanks for the reply...i tried that but am getting error that says:-
#error C2440: 'type cast' : cannot convert from 'class CString' to 'int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
thanks,
neha
Can you post your code.
You can cast characters to int, but not entire strings at once.