Hello everyone, please help with the task. Condition: Write a program that displays the first part of the character encoding table (characters with codes from 0 to 127). The table should consist of eight columns and sixteen lines. The first column should contain symbols with a code from 0 to 15, in the second - from 16 to 31, etc. Here is the code:

#include <iostream> using namespace std; int main() { int i, j, m, n; cout << "Stroki : "; cin >> m; cout << "Stolbci : "; cin >> n; cout << "ASCII\n"; char** table = new char* [m]; for (i = 0; i < m; i++) { table[i] = new char[n]; for (j = 0; j < n; j++) { table[i][j] = (n*i + j); cout << table[i][j]; } cout << endl; } return 0; } 

But it displays only ASCII characters , but I need to display characters with codes from 0 to 127.

  • @battlemanls; To format a code, select it with the mouse and click on the {} button of the editor. - free_ze
  • But I wonder how the symbol code 13 you are going to see? - KoVadim
  • @battlemanls: look at isprint . In general, the task is trivial, why do you need an intermediate table? - VladD
  • 2
    @battlemanls, You yourself write: "displays the first part of the character encoding table", and output the characters . Here are the encoding and output. For example, hexadecimal: nested loops on lines and columns printf ("% 02x% c", simple-formula-from-row-and-column numbers, last-in-column? '\ N': ''); - avp

1 answer 1

This Microsoft Visual Studio 2010 code here seems to be necessary only to remove std :: and everything should work ... accomplish your goal when you check ... it seems to work for me)))

 #include <iostream> int main() { short mass [16][8] = {0}; short ii(0); char buk(0); for (short j=0; j<= 7; j++) { for (short i=0; i<= 15; i++) { mass[i][j] = ii; ii++; } } for (short i=0; i<= 15; i++) { for (short j=0; j<= 7; j++) { buk = (mass[i][j]); std::cout<<buk<<" "; } std::cout<<'\n'; } return 0; } 
  • > This code is Microsoft Visual Studio 2010, what exactly is related to Visual Studio? - DreamChild
  • And the fact that the DEV compiler did not accept such a spelling std :: cout ... There was an error. Of course, maybe I didn't quite figure it out just ... I wrote just in case ... Does it interfere? - Pasha
  • four
    How can I tell you - you have a lot of logical errors, you confuse the compiler and IDE, claim that the most common namespace std is a Microsoft feature (and in fact you simply forgot to import this namespace, so cout does not work), and thereby giving illiterate and wrong advice, which can mislead someone inexperienced, and which, by the way. - DreamChild
  • You are right, of course. First of all, I didn’t notice from the very beginning using namespace std; since, I didn’t look through the code of this person, it’s easier for me to write my own. This line allows you not to write std ::, I know)). Secondly, I am not a very experienced programmer, when I started programming with DEV, there were a lot of errors, and I refused it. I switched to Visual Studio. Therefore, I was mistaken and said nonsense. I hope you forgive me !!! Does the code work? Or am I wrong? - Pasha
  • @pashaha, why do you need an array? (the TS was already asked, by the way) and two identical cycles? so you can write after getting acquainted with the main cycles and arrays in a thread with a picture book ... "thereby giving illiterate and wrong advice that can mislead someone inexperienced" (c) @DreamChild. - Yura Ivanov