RSS Forums RSS
Please support our C advertiser: Programming Forums

I need help on STRUCTURES and on input file

Join Date: Jul 2005
Posts: 2
Reputation: truxpinoyxrl17 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
truxpinoyxrl17 truxpinoyxrl17 is offline Offline
Newbie Poster

Re: I need help on STRUCTURES and on input file

  #3  
Jul 27th, 2005
sorry about that, its my first time here.
ok..
what im trying to do is to read from the input file and pass it into a structure.

void open_file( ifstream& master, ifstream& transact )
{
	// attempts to open the master file and transaction file
	string master;
	string transact;

	master.open( MASTER, ios::nocreate | ios::binary );
	transact.open( TRANSACT, ios::nocreate );
	if( !master )
		cout << " ** Can't open " << master << " **" << endl;
	if ( !transact )
		cout << " ** Can't open " << transact << " **" << endl;
}

void read_file( ifstream& master, ifstream& transact )
{
	char ssn[9], transact_ssn[9],
		 name[20],
		 street[20],
		 city[20],
		 state[2],
		 zip[5],
		 dummy[2];
	rec record;

	master.read((char *) &record, sizeof(record));
	while( !master.eof() )
	{
		master.read(ssn, 9);
		master.read(name, 20);
		master.read(street, 20);
		master.read(city, 20);
		master.read(state, 2);
		master.read(zip, 5);
		master.read(dummy, 2);
		master.read((char *) &record, sizeof(record));
	}

	transact >> transact_ssn;
	while( !transact.eof() )
	{
		transact >> transact_ssn;
	}
}
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:56 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC