ASCII value from multiple letters

Questions about programming languages and debugging
Post Reply
User avatar
Jontebullen
On the way to fame!
On the way to fame!
Posts: 48
Joined: 03 Apr 2007, 16:00
16
Location: south of the northpole
Contact:

ASCII value from multiple letters

Post by Jontebullen »

how do you get the ASCII value of multiple letters? I'm not a hardcore coder as you may notice.. But i'd really like to try making an easy encrypter/decrypter
I just downloaded Visual Studio 6, but i haven't had the time to try it at all.
I also have QBasic and FreeBasic, anyone now how to do it in some of those languages? or just tell me what to download an i'll do it. (is there any idea to start with c++ just like that?)
maybe you could point me to a tutorial somewhere but i haven't found anything searching the web, so please help me! :?

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
18
Location: In your eye floaters.
Contact:

Post by bad_brain »

um, do you mean something like this:
http://www.vortex.prodigynet.co.uk/misc/ascii_conv.html
:?:

User avatar
Jontebullen
On the way to fame!
On the way to fame!
Posts: 48
Joined: 03 Apr 2007, 16:00
16
Location: south of the northpole
Contact:

Post by Jontebullen »

http://www.vortex.prodigynet.co.uk/misc/ascii_conv.js kinda yeah, but isn't there an easier way, that script confuses me

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
18
Location: In your eye floaters.
Contact:

Post by bad_brain »

here's a simple one for C++:

Code: Select all

#include <iostream>
using namespace std;
int main()
{
    char word[32];
    int x = 0;
    cout << "Please enter the word (maximum 32 characters):\n";
    cin >> word;
    cout << "The ASCII for this word is:\n";
    while (word[x] != '\0')    // While the string isn't at the end...
    {
        cout << int(word[x]);    // Transform the char to int
        x++;
    }
    cout << "\n";
    return 0;
} 
and well, like the comment in the code says, the "trick" is simply to convert the char variable into an int (numeric) one...

Post Reply