C++ - Reading Char Numbers.

This is a discussion on C++ - Reading Char Numbers. within the C++ Programming forums, part of the General Programming Boards category; If your making an ASCII game or if you want to print some ASCII chars on the screen... You can ...

  1. #1
    deletedforumuser
    Guest

    C++ - Reading Char Numbers.

    If your making an ASCII game or if you want to print some ASCII chars on the screen...

    You can just write this code to show all the ASCII and their numbers.

    Code:
    #include <iostream>
    
    
    int main()
    {
       using namespace std;
    
      
       for (int i = 1; i < 255; i++)
       {
    	   cout << (char) i  << " Char number: "<< i <<endl;
    
       }
    
       cin.get();
    
       return 0;
    
    }
    This may help you if you need the ASCII Chars.
    Then you can just write this to add them.

    Example:

    Code:
    char WriteHere = 1;
    cout <<WriteHere;
    This will print WriteHere (ASCII = 1).

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    Printing every ASCII character does not create the most pleasing results.
    Not when the internal beeper joins the orchestra, at least.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    deletedforumuser
    Guest
    Haha...It just shows people how to print a char.

    It also help them to learn more about loops.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    I really think books explain the concept better, you know?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User Terran's Avatar
    Join Date
    May 2008
    Location
    Nashua, NH
    Posts
    100
    or... searching ASCII Table in Google.
    Sorry, but i'm a Code::Blocks man now.

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    Another tip: Rather than using strange numbers to stand in for characters, use the actual characters themselves, like 'a', 'b', 'z', 'A', 'B' and 'Z'. This will work for ASCII or other character sets, and it is easier to read, too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. The Interactive Animation - my first released C program
    By ulillillia in forum A Brief History of Cprogramming.com
    Replies: 48
    Last Post: 05-10-2007, 02:25 AM
  3. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  4. problem with reading and writing
    By yahn in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2006, 03:38 PM
  5. comparing fields in a text file
    By darfader in forum C Programming
    Replies: 9
    Last Post: 08-22-2003, 08:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21