Thread: Int...Char!

  1. #1
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269

    Int...Char!

    How do I write a program that you enter a number and it returns a letter?

    Example:
    Enter 1 and it returns a.
    Enter 123 and it returns abc.


    Kind of like a secret code. I thought I knew how to do this but I guess a didn't . I don't have any code .

    Needing Help,
    SirCrono6


    PHP Code:
    #include <iostream>
    using std::cin;
    using std::cout;
    using std::endl;
    int main(int argc,char *argv[])
    {
      
    cout<<"Ohhh! PHP!"<<endl;
      
    system("PAUSE"); //So!
      
    return 0;

    Last edited by SirCrono6; 12-14-2003 at 08:54 PM.
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    try this:
    Code:
    cout<<static_cast<char>(yourint);
    and use this chart to modify that to your needs/wants

    btw, what was with the PHP thing?
    Last edited by major_small; 12-14-2003 at 08:31 PM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    >BTW, what was that PHP thing?
    I have no idea...


    (Anyways...)

    That works, but not what I wanted to do .
    You see, I had it different, but thanks anyways!
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  4. #4
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Code:
    static_cast<char>(yourint + 'a' - 1);
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Originally posted by SirCrono6
    That works, but not what I wanted to do .
    You see, I had it different, but thanks anyways![/COLOR]
    what did you want it to do? Zach L. took the time out to make my code do exactly what you said you wanted...

    what do you have? you said you had no code...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  3. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  4. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM