Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://pastebin.com/u/TheWhiteFang
- //Tutorial 4 Section A (d) [convert string to ASCII]
- #include <iostream>
- #include <string>
- using namespace std;
- void convertToASCII(string letter)
- {
- for (int i = 0; i < letter.length(); i++)
- {
- char x = letter.at(i);
- cout << letter.at(i) << " = ";
- cout << int(x) << endl;
- }
- }
- int main(){
- string name;
- cout << "Please enter a string:\n";
- getline(cin, name);
- convertToASCII(name);
- cout << endl;
- cout <<"Your entered string is: "<< name <<" and the length is "<< name.length() << endl <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement