473,320 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Characters for the ASCII Codes

Hi,

Need some help figuring out the following:

Write a program that uses a loop to display the characters for the ASCII codes 0 through 127. Display 16 characters on each line.
Mar 24 '08 #1
3 3037
gpraghuram
1,275 Expert 1GB
Hi,

Need some help figuring out the following:

Write a program that uses a loop to display the characters for the ASCII codes 0 through 127. Display 16 characters on each line.

You can easily achieve this using printf with and format specifier.
But tell me what have you tried on this?


Raghuram
Mar 24 '08 #2
So this is the issue that I am running into:

cout << ((char) i);
j= (i+1)%16;
if (j == 0)
cout << "\n";

ASCII codes 10 is "Line Feed" and 13 is "Carriage Return". Both of these will cause the line to terminate prematurely if they are not handled with separate considerations.

This is the ouput so far:

☺☻♥♦♣
♫☼
►◄↕‼¶§▬↨↑↓→←∟↔▲▼
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~
Mar 24 '08 #3
So this is the issue that I am running into:


cout << ((char) i);
j= (i+1)%16;
if (j == 0)
cout << "\n";

ASCII codes 10 is "Line Feed" and 13 is "Carriage Return". Both of these will cause the line to terminate prematurely if they are not handled with separate considerations.

This is the ouput so far:

☺☻♥♦♣
♫☼
►◄↕‼¶§▬↨↑↓→←∟↔▲▼
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~
I figured it out with an if/else statement for ascii character 10 and 13.
Mar 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: mikeyjudkins | last post by:
I have an XML file containing localized strings in 9 languages, encoded in Unicode (UTF-8). Im trying to parse this XML document via XSLT (Apache Xalan) to selectively render localized strings...
3
by: Jim Irvine | last post by:
I have a small database made up of 2 tables. I have a report that is driven from a query. On the report are a couple of fields linked to memo boxes in the table. Everytime I run the report I get...
8
by: Ess355 | last post by:
Hi, In the debugger at run time, characters like é are not recognised by their normal ASCII number, but something like -8615722... . I've seen this number before, it means "rubbish" right? So...
12
by: wob | last post by:
Hi there, I wish to show some special characters such as the char for "alpha" and the symbol for degrees.. Anyone please give me some suggestions how to do that? Thank you very much! Owen
4
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII...
4
by: Dirk Reske | last post by:
Hello, i have following source, to be translatet into C# for (i = 1; i < len; i++) key = lock xor lock; key and lock are strings in C# xor = ^
3
by: JSM | last post by:
Hi, I am just trying to port an existing simple encryption routine to C#. this routine simply adds/substracts 10 ascii characters to each character in a text file (except quotes). The routine...
2
by: Engineerik | last post by:
using vb.net 2003, I am reading an ascii text file which is shared with a legacy DOS program. The characters "«" (ascii code 171) and "¬" (ascii code 172) are used in the file. The DOS app...
19
by: many_years_after | last post by:
Hi,everyone: Have you any ideas? Say whatever you know about this. thanks.
3
by: orgelizer via AccessMonster.com | last post by:
I'm trying to enter some specific special characters (Ω, ±, ≥, ≤ for example) in Access. Knowing that ASCII should be ASCII, but with variations (the spice of life, right?), using the "Hold...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.