Merging files (code included)
Here are the 2 files that I am working with. Attahced is the code that I used to get as close to a solution as I could. The two problems that I have are:
1) When there is a space in the item name the str stops copying/moving.
2) For some reason, my code is in some sort of indefinite loop. It does not stop at the end of file, it just keeps printing to the screen.
FILE 1: FILE 2:
item code cat price # code
BASKETBALL 4935 SG 24.95 39 4935
BIKE 4505 SG 299.99 47 4505
BLENDER 4240 HW 223.95 69 4240
CAMERA 9128 SW 26.95 97 9128
CANVAS 5626 SG 26.95 181 5626
CARB 9296 AP 31.95 236 9296
CORN POPPER 6822 HW 29.95 244 6822
COVER 6115 HW 25.95 265 6115
CROWBAR 1282 HW 27.95 305 1282
DARTBOARD 7998 SG 12.95 310 7998
FUEL GAUGE 3813 SG 151.99 393 3813
GAS GRILL 3000 AP 149.99 395 3000
GRIDDLE 3752 HW 39.99 452 3752
INJECTOR 3116 HW 150.99 474 3116
IRON 5634 HW 24.95 493 5634
JACK 1528 HW 13.95 536 1528
MICROWAVE 6044 HW 30.95 541 6044
NET 5791 AP 15.95 605 5791
PRESS 9547 HW 25.95 635 9547
REFRIG 4111 AP 27.95 745 4111
STRUTT 3804 AP 152.99 748 3804
TIRE 2674 AP 32.95 776 2674
TREADMILL 7348 SG 349.95 780 7348
VOLLEYBALL 8066 SG 14.95 846 8066
WASHER 9145 AP 399.99 987 9145
Both files have the same code (already sorted). I was trying to open both files, compare the code #, and if equal, save this information to a 3rd file.
Thanks for any help you can provide,
Alan
update attempt at merging
I have made Salem's suggested changes. I receive 1 error and cannot determine why. It comes on the 2nd char buff[BUFSIZ] line.
If anyone can help, please let me know.
Thanks,
Alan