|
-
October 29th, 2010, 01:05 PM
#1
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
-
October 29th, 2010, 01:37 PM
#2
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.
-
October 29th, 2010, 01:52 PM
#3
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
-
October 29th, 2010, 02:04 PM
#4
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?
-
November 2nd, 2010, 11:58 AM
#5
Re: Need Help Regarding converting String to ASCII value
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|