ANSI output

This is a discussion on ANSI output within the C++ Programming forums, part of the General Programming Boards category; Code: #include <curses.h> int main() { initscr(); raw(); int a = 0; do { addch(a); refresh(); a++; } while (a ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    26

    ANSI output

    Code:
    #include <curses.h>
    
    int main()
    {
      initscr();
      raw();
      int a = 0;
      do
      {
        addch(a);
        refresh();
        a++;
      }
      while (a < 256);
      getch();
      endwin();
      return 0;
    }
    This doesn't output the full 0 - 255 range of characters. I need to print them all to screen. Is it a problem with ANSI?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Not all characters in that range are printable.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    Yes they are *blinks*

    Try ZZT for instance; an oop based programming gcs

    So, anone else (not using linux, who knows about the ansi system)?

  4. #4
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Quote Originally Posted by sufthingol
    Yes they are *blinks*

    Try ZZT for instance; an oop based programming gcs

    So, anone else (not using linux, who knows about the ansi system)?
    King of the non sequitur?

    I fail to see how it can be a problem with ANSI.
    Quote Originally Posted by Wikipedia
    The American National Standards Institute (ANSI) is a private, non-profit standards organization that produces industrial standards in the United States
    It's not really a problem with ASCII either.
    Quote Originally Posted by Wikipedia
    There are 95 printable ASCII characters, numbered 32 to 126.
    I think the problem is that you don't know what you're talking about. Try being a little less arrogant. It's a safe assumption that some people know more than you.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    Excuse me? How dare you call me arrogant?

    I disagree. I think that with a CERTAIN method (that I don't know) ALL of the chars are printable. I've seen them all printed in the ZZT dos program. In fact, if you run that code I posted in the start of the thread, you will see that all the chars beyond 126 ARE printed. At least, they are on my Windows ME system. And before anyone attacks me for using windows, I already know Microsoft is a bunch of ......... But I have always refused to use unix as I don't have the time to learn it. Thank you.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Keep it friendly, or I'll close the thread

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Whether you are using Microsoft or Linux will not alter the fact that it is certainly true that not all of the characters represented by the values 0 - 255 are printable in the simple sense of the technique.

    Consider the value zero, a NUL character, doesn't print. You may have had something that prints a splat when it can't translate what you are saying, that is not the same thing as printing the actual character.

    If it helps you, I'll add the *blinks*.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  8. #8
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    437 codepage

    http://en.wikipedia.org/wiki/Codepage_437

    stop holding back info

  9. #9
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Thats not ASCII, ASCII is 7 bits, (Extended ASCII added use for the eigth). Also, notice that page specificly mentions DOS/Windows, in Linux all I see is a box with the hex inside of it for the unprintable characters.
    http://en.wikipedia.org/wiki/ASCII
    That is ASCII, and as its states, their are 95 printable characters in the ASCII code set, which is the default for C and C++, as far as I know. I believe some regions changed some of the character codes though, to cover accented characters, which is why you might have to use trigraphs.

    Want to check it out? try
    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
       char current = char(0);
       for (int i = 0; i < 128; i++)
       {
          current = char(i);
          cout << current << '\t';
          if (i%10 == 0)
          {
             cout << endl;
          }
       }
       cout << endl;
    }
    look at this for the output I got in Linux. You will notice you don't see any thing but blank spaces at first.
    Last edited by Xipher; 03-08-2005 at 09:39 AM.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  10. #10
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    1. I am using Win32, not linux, so please if anyone knows about windows, help me

    2. I very much *do* want to print the characters that I *know* are able to be printed. May I have some help with *that* please?

  11. #11
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,417
    > I am using Win32
    And which compiler?
    I can see from your original post that you're using a curses library - which one is that?

    As others have said, anything outside the range 32 to 126 is horribly implementation specific, so we need more details if there is to be any chance of further progress.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  12. #12
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Using Windows XP, I was able to print symbols for 1-6, 11, 12, 32-254. The other character codes used their ASCII behavior. I did note that you can see the symbols for 7,8, and 13 by saving them to a file and then opening the file with the edit command. Seeing as the edit command can do it, there must be some way to get C++ to do it too.

    I'd like to apologize for my previous post. It was a bad day, and I was unnecessarily gruff.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  13. #13
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    As its been said, the characters outside that range, are implementation specific. You might want to find the doc's dealing with your compiler. Also, why must you be able to print them out? I don't see any reason why you need to print them all to a screen.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  14. #14
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    stop holding back info
    lol!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  15. #15
    Registered User
    Join Date
    Mar 2005
    Posts
    26
    Ok...I am using DevvC++ bloodshed and pdcurses from http://gnuwin32.sourceforge.net/packages/pdcurses.htm

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 02:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 02:29 PM
  3. Replies: 4
    Last Post: 11-30-2005, 03:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 04:27 AM

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