So my prof wants us to to format our output in a table, i have everything but the actual output code.
Display the character for the ASCII codes 32 through 127, inclusive. Using a loop the output will result in a table format. Put the title ASCII Codes/Characters centered above the table.
The next line the table will be the column headings to identify the material in the table.
For each code value value in range given print both the code and the character for that code.
Make the printout readable with sets for 6 codes & the corresponding characters on each line printed
(that means 12 entries will be on each line). Use setw to space out each line in the table that is created.
Well I don't think I'm supposed to just give you the code... you're supposed to figure it out yourself.
Here are 3 problems (there are more) with the code you posted:
1. Your initial value for "letter" is 0, when it should be 32.
2. Your loop iterates a total of 128 times (0 to 127) when it should be 96 times.
3. Each line of the table is supposed to be 6 sets of 2, for 12 entries, not 12 sets of 1.
I currently have it outputting the numbers and symbols, but I can't seem to get the spacing right, and the top row keeps splitting in half and starting on the next row. It doesn't hurt to just point out something in a segment of code, I've helped people before. I fixed part of it.
This is the loop I used to generate the chart (basically your whole assignment):
1 2 3 4 5 6
for(int letter = 32; letter < 128; letter++)
{
if ((letter - 32) % 6 == 0)
fout << "\n||";
fout << setw(5) << letter << " | " << setw(3) << (char)letter << " ||";
}
The fout is because I'm outputting to a file instead of the console so I could copy/paste the table to my post, and because my console window only has a width of 80 characters per line.
i already figured that out, i tweaked it a little, I use this more as a sounding board to bounce things off of, all I can't seem to do now, is center the title and add column headings