Our college changes 18 weeks semester to 16 semester, so our CS professor cannot finish teaching the last important chapter which is related with my problw\em.
This is program C problem
Anyone can help me with this problem, please!!!!!!!!!
This is the problem:
3. Several input text files have been provided as input to your program.
a) Write a function to combine these files into a single file.
b) Write a function to take care of multiple spaces and replace each occurrence of a multiple spaces with a single space.
c) Write a function to examine the words in your text file and count the number of words. Words are separated by white spaces i.e. space, newlines or tabs.
d) Write a function to count the word length in the file. Do not count punctuation characters when determining word length. Report on the screen the shortest and longest words.
Test all the above functions. Try it first by using your own text files" Myfile1" and" Myfile2" (write two short text files, about ten words each). Then use the data posted http://www.mtsac.edu/rvhpop/proj4-110.txt
the hint is that it is similar to this code:
#include <stdio.h>
main()
{
FILE
*inptr, *outptr;
int
c,empno;
float
pay;
char
empname[20];
/************************************************** **************/
/* open the input and the temporary files, with error checking */
/************************************************** **************/
inptr = fopen("payrates", "r");
if (inptr == NULL)
{
printf("Problem opening file \"payrates\" \n");
exit(1);
}
outptr = fopen("tempfile","w");
if (outptr == NULL)
{
printf("Problem opening output file...\n");
exit(1);
}
/************************************************** **************/
/* read the file, update the pay field, write to the temp file */
/************************************************** **************/
c = fscanf(inptr,"%d %s %f",&empno, empname, &pay);
while (c != EOF)
{
pay = pay*1.05;
fprintf(outptr,"%4d %20s %6.2f\n",empno,empname,pay);
c = fscanf(inptr,"%d %s %f",&empno, empname, &pay);
}
/************************************************** **************/
/* make sure you close the files, otherwise remove and rename */
/* will not work correctly. */
/************************************************** **************/
fclose(inptr);
fclose(outptr);
/************************************************** **************/
/* remove the old "payrates" file, rename "tempfile" "payrates" */
/* note the error checking. */
/************************************************** **************/
/* USE remove ON THE MAC SYSTEMS, unlink ON UNIX */
/*if((remove("payrates")) == -1) */
if((unlink("payrates")) == -1)
{
printf("remove didn't work...\n");
}
if((rename("tempfile","payrates")) != 0)
{
printf("rename error...\n");
}
}
Pleas help
My email: nt91rx78@hotmail.com