Programming tutorials online .NET, Java, C++, Visual Basic, and More
 

Home
.NET Tutorials
General Programming Tutorials
Community/Forums
Site Extras

 

C/C++ Forum
 

Open forum for posting questions or comments regarding C/C++.


POST REPLY
Posted By: Telnet   6/8/2007 10:16:00 AM
Reply To: richie2021 who posted...
 
#include
#include
#include//string header is needed for strcpy
int main()

{
struct {
char origin[50];
char destination[50];
char flight[10];
char aircraft[3];
char days_of[7];
char departure[4];
char arrival[4];
char begin_date[10];
char end_date[10];
}
flight_details[1679];

FILE *fp;
fp=fopen("iaschedule-07(edit).csv","r");
char buf[50];
int i;
while( fgets(buf,sizeof(buf),fp) != '\0')
{
strcpy(flight_details[i].origin, strtok(NULL,","));
strcpy(flight_details[i].destination, strtok(NULL,","));
strcpy(flight_details[i].flight, strtok(NULL,","));
strcpy(flight_details[i].aircraft, strtok(NULL,","));
strcpy(flight_details[i].days_of, strtok(NULL,","));
strcpy(flight_details[i].departure, strtok(NULL,","));
strcpy(flight_details[i].arrival, strtok(NULL,","));
strcpy(flight_details[i].begin_date, strtok(NULL,","));
strcpy(flight_details[i].end_date, strtok(NULL,","));
++i;
}

printf("print details\n");

for(int j=0; j {
printf("Origin : %s", flight_details[j].origin);
printf(", Destination : %s\n",flight_details[j].destination);
}

fclose(fp);//this closes the file
return 0;
}

Hi richie2021
I hope i have solved your problem. Anyways tell me what you need it for and give me the question to this problem Please.

Thanx in advance





 
Sign In
Email
Password
  Forgot my password

Search

Featured Book

Introducing Microsoft .Net, Third Edition ($19.79)
Introducing Microsoft .Net, Third Edition


Featured Software

Microsoft Visual Studio Standard 2005 ($249.99)
Microsoft Visual Studio Standard 2005





 
© 2022 Ammastore.org
All Rights Reserved
COMPUTER SCIENCE HOMEWORK | Privacy/Disclaimer