I simplified a little and it works fine. Your work is not finished. Please try this,
#include <usual.h>
#define MAX_NAME_CHARS 15
#define MAX_DATA_FILE_LINE_LENGTH 32
#define MAX_GAME_RESULTS 128
int main( void )
{
FILE *inp2b;
typedef struct game_results
{
char first_team_name[MAX_NAME_CHARS];
int first_team_score;
char second_team_name[MAX_NAME_CHARS];
int second_team_score;
} game_results_t;
game_results_t game_results[MAX_GAME_RESULTS];
char data_file_line[MAX_DATA_FILE_LINE_LENGTH][MAX_DATA_FILE_LINE_LENGTH];
int errorcode = 0;
int i = 0;
//errorcode = fopen_s(&inp2b,"C:\\Users\\Cody\\Documents\\Visual Studio 2012\\DATAFILES FOR PA2\\input2b.dat","r");
inp2b = fopen( "C:\\testdat\\input2b.dat", "r" );
if ( inp2b == NULL )
errorcode = 1;
if ( errorcode != 0 )
{
printf( "Error opening 2nd data file!\n\n" );
return ( 0 );
}
else
{
printf( "\n\n\nFile was opened successfully!\n\n" );
}
i = 0;
while ( !feof( inp2b ) )
{
fgets( data_file_line[i], MAX_DATA_FILE_LINE_LENGTH, inp2b );
puts( data_file_line[i] );
printf( "\n" );
// sscanf_s(data_file_line[i],"%s %d %s %d",game_results[i].first_team_name,&game_results[i].first_team_score,game_results[i].second_team_name,&game_results[i].second_team_score);
sscanf( data_file_line[i], "%s %d %s %d", game_results[i].first_team_name,
&game_results[i].first_team_score,
game_results[i].second_team_name,
&game_results[i].second_team_score );
printf( "\n\n %s %d %s %d \n\n", game_results[i].first_team_name,
game_results[i].first_team_score,
game_results[i].second_team_name,
game_results[i].second_team_score );
i++;
}
fclose( inp2b );
return ( 0 );
}