]Hi I'm not the best at C but I'm trying to write a C function that basically opens a text file with assembler language does a syntax error check on it and then converts the binary data into hex.
This is my code so far:
Code:
#include <stdio.h>
#include <string.h>
int main(void)
{
FILE*fname;
char prompt;
char filename[15];
char text[100];
printf( "Please enter the name of the file you wish to open: \n" );
fgets(filename, sizeof(filename), stdin);
filename[strlen(filename)-1]='\0';
fname = fopen(filename, "r+");
if (fname == NULL)
{
printf( "ERROR the file you have chosen cannot be opened \n" );
printf( "Please make sure the file exists \n");
return;
}
while (fgets(text,100,fname) != NULL)
printf("\n%s", text);
scanf("\n%c",&prompt);
}