OK...i dont know if its too early at work, or what...but i shouldnt be having problems reading in some data and storing them into linked lists...does anyone see any errors with this code?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
class int_node
{
public:
long item_num;
int_node *next;
};
class text_node
{
public:
char descr[150];
text_node *next;
};
int main()
{
FILE *masterIntIn;
masterIntIn = fopen("C:\\Cplusplus\\dm\\bin\\master_int.txt" , "r");
FILE *itemLocateNumIn;
itemLocateNumIn = fopen("C:\\Cplusplus\\dm\\bin\\item_location_num.txt" , "r");
FILE *matchItemsOut;
matchItemsOut = fopen("C:\\Cplusplus\\dm\\bin\\matching.txt" , "w");
FILE *itemLocateDescrIn;
itemLocateDescrIn = fopen("C:\\Cplusplus\\dm\\bin\\item_location_descr.txt" , "r");
int_node *current_master;
int_node *root_master;
root_master = new int_node;
root_master->next = NULL;
current_master = root_master;
int_node *current_lnum;
int_node *root_lnum;
root_lnum = new int_node;
root_lnum->next = NULL;
current_lnum = root_lnum;
text_node *current_descr;
text_node *root_descr;
root_descr = new text_node;
root_descr->next = NULL;
current_descr = root_descr;
while ( !feof( itemLocateDescrIn ) )
{
char tempCh[150];
fgets( tempCh , itemLocateDescrIn , 150 );
strcpy( current_descr->descr , tempCh );
current_descr->next = new Text_node;
current_descr = current_descr->next;
current_descr->next = NULL;
}
while ( !feof( masterIntIn ) )
{
long tempLong;
fscanf( masterIntIn , "%ld" , &tempLong );
strcpy( current_master->item_num , tempLong );
current_master->next = new Int_node;
current_master = current_master->next;
current_master->next = NULL;
}
while ( !feof( itemLocateNumIn ) )
{
long tempLong;
fscanf( itemLocateNumIn , "%ld" , &tempLong );
strcpy( current_lnum->item_num , tempLong );
current_lnum->next = new Int_node;
current_lnum = current_lnum->next;
current_lnum->next = NULL;
}
current_descr = root_descr;
current_master = root_master;
current_lnum = root_lnum;
while ( current_master->next != NULL )
{
printf("%l \n" , current_master->item_num);
current_master = current_master->next;
}
return 0;
}
thanks
~omega