FILE IN OUT probelem

I printed out more than one name in each line, who can explain why it will be caused

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  #include<stdio.h>
int main(){
	FILE *fp;
	int n,size=0,i=0,s;
	int no[256];
	char name[300][15];
	float price[256],max=0;
	fp=fopen("catalog.txt","r");
	if(fp==NULL){
		printf("The file open failed");
	}
	else{
			while((n=fscanf(fp,"%d %s %f",&no[size],name[size],&price[size]))==3){
				size++;
	}

for(i=0;i<size;i++){
	printf("%d %s %f\n",no[i],name[i],price[i]);
}
}
fclose(fp);
}
/*catalog.txt
492496 S-Brite-#325-Urethane-Laminate 12.90
430314 S-Brite-#7700-Pan-Scrubber-Green 16.90
430306 S-Brite-#7701-Pan-Scrubber-Blue 18.50
330282 Scotch-Brite-Tub&Sink-Scrb-Spge 9.90
530980 Scotch-Brite-Scour-Pad-#103hk-3Pieces 7.90
457259 Scotchbrite-Spiral-Ball 7.90
457325 Scotchbrite-Multi-Pur-Wipe 14.90
326454 Scotchbrite-Cleaning-Pad 5.90
326447 Scotchbrite-Soft-Scour-Sponge 9.50
326462 Scotchbrite-Cellucose-Sponge 13.50
262931 Scotchbrite425-Kitch-Scrub-Sponge 7.90
262949 Scotchbrite435-Scrub-Sponge 7.90
525717 Selley-Super-Cloth 14.50
607499 Vileda-Sp.Absorb-Scourer 9.90
276998 Vileda-Household-Cloth 12.90
476226 Vileda-Sponge-Cloth 14.80
607515 Vileda-Flex-Flat-Scourer 8.90
308569 Wc-3030b-Wiping-Cloth-30x30cm 4.50
259911 Cf-Aa0084y-Hand-Towel-13x30.5 6.50
257485 Cf-Aa0272y-H/T-Stripe-9X19.5 3.20
259895 Cf-Ad1063y-Tea-Towel-12x12 3.50
384503 Cf-G.M-Aa67y-Hand-Towel-13x28 9.20
384511 Cf-G.M-Aa8by-Hand-Towel-13x31 9.50
462556 Th-Towel-H1016-Tea-Towel-12X12 4.90
577452 Th-Towel-T-979-Hand-Towel-12x12 4.20
487116 Db-Brand-Adaptor-W/Light-13a/5a 13.90
487108 Db-Brand-13a-Adaptor-W/Light 13.90
487132 Db-Brand-13a-Plug-W/Switch 14.90
487140 Db-Brand-15a-Adaptor-W/Light 15.90
487157 Db-Brand-5a-Plug-W/Switch 11.90
487165 Db-Brand-15a-Plug-W/Switch 14.90
487173 Db-Brand-6w-13a-Socket-Switch 89.90
487231 Db-Brand-4w-13a-Socket-Switch 84.90
487249 Db-Brand-3w-13a-Socket-Switch 74.90
487264 Db-Brand-3w-13a-Socket-Light 156.90
487272 Db-Brand-4w-13a-Socket-Light 62.90
626606 Philips-Starter 7.20
757799 First-Choice-25w-Cl-Lustre-E27-2pc 7.90
757807 First-Choice-60w-Cl-Lustre-E14-2pc 7.90
757815 First-Choice-25w-Cl-Lustre-E14-2pc 7.90
757948 First-Choice-60w-Frost-Candle-E14-2pc 7.90
757930 First-Choice-40w-Frost-Candle-E14-2pc 7.90
757922 First-Choice-25w-Frost-Candle-E14-2pc 7.90
757914 First-Choice-60w-Clear-Candle-E14-2pc 7.90
757906 First-Choice-40w-Clear-Candle-E14-2pc 7.90
757898 First-Choice-25w-Clear-Candle-E14-2pc 7.90
757872 First-Choice-40w-Fr-Lustre-E27-2pc 7.90
757773 First-Choice-60w-Cl-Lustre-E27-2pc 7.90
757781 First-Choice-40w-Cl-Lustre-E27-2pc 7.90
757880 First-Choice-60w-Fr-Lustre-E27-2pc 7.90
757856 First-Choice-60w-Fr-Lustre-E14-2pc 7.90
757864 First-Choice-25w-Fr-Lustre-E27-2pc 7.90
757823 First-Choice-40w-Cl-Lustre-E14-2pc 7.90
757831 First-Choice-25w-Fr-Lustre-E14-2pc 7.90
*/
An array of 15 characters is not enough to store some of those names.
oh i am fking dump.Thank you bro
Topic archived. No new replies allowed.