I made a program to print an ASCII table up to a certain range (like ASCII from 0 to 104).
#include <stdio.h>
int main(void)
{
int n;
printf("\n\nthis program will print list of ASCII values for your computer enter the upper limit for the range - ");
scanf("%d", &n);
printf("\nDECIMAL\tCHARACTER");
for (int i = 0; i <= n; i++)
{
printf("\n %d | %c", i, i);
// printf("\n-------------");
printf("_"); //when i include this "undescore" it causes problems, the code stops at 27th ASCII character and gets stuck.
}
return 0;
}
The 27 decimal corresponds to ASCII SYSTEM CODE - [ESCAPE].
None of the following works, and the code stops at the 27th ASCII character:
printf("__");
//double or multiple underscore does not work.
printf("\n_");
//this doesnt work either.
printf("//_");
//somehow this works.
If I remove that printf("_");
part then the code does not stop at 27 and runs smoothly, the code only stops when I use the underscore (_
) character.
If I use a different character (-
, *
, etc), it runs smoothly.
What can the problem be? Could it be something related to macros?
Edit- when I replaced 'printf("_");' with 'printf("n");' thinking it would perform the same as '\n' some weird language popped up and the language of the terminal changed. when '_' is replaced by 'n'