![]() |
| ||
| Prog to list ASCII codes (beginners' stuff) Hi, I just started a program containing every single prog we have done for school so far and added some private stuff. Searching through my older files I found a prog which lists all Integers between 1 and 255 and their respective ASCII char, so I decided to include it into my 'collection'. The problem is that 'twas a Win32 executable and we're working under DOS. Well actually this wouldn't be much of a problem, but the script seems no to work under DOS. Well, first of here's the script: # include <iostream.h> As I stated, no problems under Win32, but under DOS it stops at 26 and after pressing a key again the screen gets cleared again and stays black. So my question is..is there any way to get something like this running under DOS? I tried a simple "cin>>intvar; charvar=intvar; cout<<charvar;" aswell, but any value above 25 simply results in nothing being put out. Well, thanks in advance.~ |
| ||
| Re: Prog to list ASCII codes (beginners' stuff) Skip 26. Or better yet, skip printing everything non-printable. #include <stdio.h> |
| ||
| Re: Prog to list ASCII codes (beginners' stuff) Quote:
Wow, thanks for the fast reply. Well, but how to skip them most easily? The first and more or less only thing that comes into my mind is like: if ( i != 26 && i != anotherone && i != yetanotherone &&... |
| ||
| Re: Prog to list ASCII codes (beginners' stuff) [Oops. I see your reply beat my edit.] I'd use isprint. #include <stdio.h> |
| ||
| Re: Prog to list ASCII codes (beginners' stuff) I see, thanks again. But seeing this... The output under Win32 is like: 1 - ☺And so on, so... Aint I able to display the 255 ones of those under Dos? |
| ||
| Re: Prog to list ASCII codes (beginners' stuff) Check out http://www.asciitable.com/ The full list of ASCII characters are there. The function isprint() knows which of the characters are printable. isprint() returns a nonzero value if the input is a printable character, including the space character (0x20 – 0x7E). The other characters are either extended, or do other features which aren't print friendly. More information on isprint() isprint() is included in the ctype library, ctype.h: int isprint(int c); » This function returns nonzero if c is a space or a character for which either isalnum() or ispunct() returns nonzero. int isalnum(int c); » This function returns nonzero if c is any of or other locale-specific alphabetic character. According to AsciiTable.comint ispunct(int c); » This function returns nonzero if c is any of the following or other implementation-defined punctuation character: According to AsciiTable.com Hope this helps, - Stack Overflow |
| ||
| Re: Prog to list ASCII codes (beginners' stuff) 4 Attachment(s) Thanks, might be quite of use, though probably not directly in what I'm thinking of. See the attachments, I just want the fourth attachment (Dos, page2) to be like the second one (W32, page2). |
| ||
| Re: Prog to list ASCII codes (beginners' stuff) Quote:
|
| ||
| Re: Prog to list ASCII codes (beginners' stuff) Quote:
|
| ||
| Re: Prog to list ASCII codes (beginners' stuff) That was all I actually wanted to know. Thanks once again. ^^ |
| All times are GMT -4. The time now is 10:11 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC