Hi,
I want my program to print sentences for me from a file. I
CODE
t is doing that but without the spaces in between. What's going wrong ? The code is given below & the input & output files too.
Code
[code]
#include<stdio.h>
main()
{
FILE *ifp, *ofp;
char *mode = "r";
char outputFilename[] = "textout";
ifp = fopen("text", mode);
if (ifp == NULL) {
fprintf(stderr, "Can't open input file in.list!\n");
exit(1);
}
ofp = fopen(outputFilename, "w");
if (ofp == NULL) {
fprintf(stderr, "Can't open output file %s!\n",
outputFilename);
exit(1);
}
char sentence[1000];
while (fscanf(ifp, "%s", sentence) != EOF){
fprintf(ofp, "%s", sentence);
}
fclose(ifp);
fclose(ofp);
}
Input file:
1. The keeper keeps the keep in the night.
2. The keeper sleeps in the night.
Output file:
1.Thekeeperkeepsthekeepinthenight.2.Thekeepersleepsinthenight.
This post has been edited by c_sen28: 27 Aug, 2008 - 07:42 AM