所以我有一个程序,它获取一个文件并逐个字符地读取并打印字符和十六进制等价物。`
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *labFile;
char buf;
labFile = fopen("lab1.dat", "r");
if (labFile == NULL) perror("Error opening file\n");
while( (buf = fgetc(labFile) ) != EOF){
if(("%x", buf)< 16){
printf("%c 0%x\n", buf, buf);
}
else
printf("%c %x\n", buf, buf);
}
fclose(labFile);
return 0;
}
` 除一件事外,该程序按我需要的方式运行。我需要程序在顶部输出十六进制数字,然后在数字正下方输出字符,这个过程需要水平继续。
任何帮助将不胜感激!