Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,420 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,980 people online right now. Registration is fast and FREE... Join Now!




ASCII

 
Reply to this topicStart new topic

ASCII, i want to print all the ascii characters from 0 to 255 using c++

ravikumar.vemula
26 Jan, 2008 - 09:58 AM
Post #1

New D.I.C Head
*

Joined: 26 Jan, 2008
Posts: 1

CODE
#include<iostream.h>
#include<ctype.h>

void main()
{
int i;
for(i=0;i<256;i++)
cout<<(char)(i);
}


Mod Edit: added code tags: code.gif
User is offlineProfile CardPM
+Quote Post

#include<wmx010>
RE: ASCII
26 Jan, 2008 - 10:07 AM
Post #2

D.I.C Head
**

Joined: 19 Jan, 2008
Posts: 75



Thanked: 1 times
My Contributions
I don't see anything wrong with your code. It does the job.
but for readability purposes you could put it this way:

CODE

#include<iostream>

using namespace std;

int main()
{
    for (int i = 0; i < 256; i++)
    {
        cout << "  " << (char)(i);

        if (i % 15 == 0)
            cout << "\n\n";
    }

    cout << "\n\n";

    system("PAUSE");
    return 0;
}


This post has been edited by #include<wmx010>: 26 Jan, 2008 - 10:29 AM
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: ASCII
26 Jan, 2008 - 09:35 PM
Post #3

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,859



Thanked: 51 times
Dream Kudos: 550
My Contributions
Most of the characters before 0x20 are control character and don't display well (or at all).

check out asciitable.com


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 04:18AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month