Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write pseudo code and code for a program vt.c which reads characters from stdin

ID: 3586622 • Letter: W

Question

Write pseudo code and code for a program vt.c which reads characters from stdin and writes to stdout. For each character input, it should print on a single line: (a) the ASCII name of the character, and (b) the hexadecimal value of the character. The program should stop when it encounters an EOF condition on stdin (which can be entered from the keyboard by typing ). char asciiname[] = "NUL" "SOH" "STX" . . .. . ."; the output should be something like this

%cat vt.out

NUL, 0

VS, 1f

", 22

A, 41

TAB, 9

DEL, 7f

:, 3a

J, 4a

~, 7e

`, 60

[, 5b

SP, 20

Explanation / Answer

code for above question:

#include<stdio.h>
int main()
{
FILE *ptr; //pointer for required file
int c;
ptr=fopen(output.txt,"r"); // opens file in read mode
if(!ptr)printf("file cannot be opened");  
else{
while(c=fgetc(ptr)!=EOF)
{
printf("%c , %x",c); //%c prints in ascii name and %x in hexadecimal form
}
}
return 0;
}

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote