Hello everyone. I'm having a problem in a program I'm working on and I broke the program up into this small bit here. I've done searches on the forum and tried to input this file from what I've seen on other posts but what I cannot figure out is why the strings are not getting read correctly. Can anyone help?
The error is that it's not printing the first 2 strings being read. The last (which is a char) gets read and prints out just fine strangely enough.
Input:
Code:
PROGA 0000 C
LISTB 0000 I
ENDB 0000 I
P 0048 R
BR 104B R
B1 104E R
B2 1061 R
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
FILE *st_fptr,
*fopen();
int main( void )
{
char temp_name[6];
char temp_value_str[4];
char temp_type;
if ( ( st_fptr = fopen ( "symtab.txt", "r" ) ) == NULL )
{
printf ( "Can't open 'symtab.txt' file!\n" );
getchar();
exit(1);
}
while ( !feof ( st_fptr ) )
{
fscanf ( st_fptr, "%s%s%s", temp_name, temp_value_str, &temp_type );
printf ( "name: %s\n", temp_name );
printf ( "string: %s\n", temp_value_str );
printf ( "type: %c\n\n", temp_type );
}
printf ( "Press return to continue..." );
getchar();
return 0;
}