this is my code:
Code:#include <stdio.h>#include <string> using namespace std; int main(){ FILE *file1; // fisrt file int Num_Of_Bays, Docking_ID, Max_size,Time_Taken; double Chargs; char Harbour_Name; int input_status,i; file1 = fopen("Port_Data_File.txt", "r"); /* Open file first.txt */ if (file1 == NULL) { /* Couldn't open the file. */ printf("Input file not found.\n"); return -1; /* Non-zero means error. */ } for (i=0;i<Harbour_Name;i++){ i!=EOF; fscanf(file1,"%d%c%d%d%1f", &Num_Of_Bays,&Harbour_Name,&Docking_ID,&Max_size,Time_Taken,&Chargs); } printf("\n"); printf("NUMBER OF DOCKING BAYS ARE %d HARBOUR NAME IS %c\n",Num_Of_Bays,Harbour_Name); printf("\n"); printf("DOCKING ID MAXIMUN SIZE OF BAY TIME TO UNLOAD CHARGE\n"); printf("========== =================== ============== ======\n"); printf("%d%d%f\n", Docking_ID,Max_size,Time_Taken,Chargs); system("PAUSE"); return EXIT_SUCCESS; }
this is the txt ( 4 columns):
notice that there is a space between 2234,10000,20000 and 12.50 ....................ect
10 Eilat
2234 10000 20000 12.50
2235 12400 24800 22.78
2236 8300 16600 34.55
2237 11786 12500 14.34
2238 16901 25023 9.78
2239 19076 38678 23.06
2240 14238 24356 127.08
2241 511 1256 13.50
2242 45403 85000 137.00
2243 600 1000 17.86



LinkBack URL
About LinkBacks



