Ok, this is what I've got so far... But this seems to only be half of what I need.
I have not figured out how to display the words on seperate lines, or count the number of letters and number of words... any help perhaps?????
Code:
#include <stdio.h>
#include <ctype.h>
#include <stdafx.h>
#define size 65
int main(void)
{
char input[size],
output[size];
char a;
int words=0, end=1;
FILE *inp,
*outp;
printf("Enter read file\n");
for(scanf("%s", input); (inp=fopen(input, "r"))== NULL; scanf("%s", input))
{
printf("Can't open %s\n", input);
printf("Re-enter file name> ");
}
printf("Enter write file\n");
for(scanf("%s", output); (outp=fopen(output, "w"))== NULL; scanf("%s", output))
{
printf("Can't open %s\n", output);
printf("Re-enter file name> ");
}
a=getc(inp);
while(a != EOF)
{
if(isalpha(a) || isdigit(a))
{
putc(a, outp);
end=1;
}
else if(isspace(a) && end)
{
end=0;
fprintf(outp, "n");
words++;
}
a=getc(inp);
}
printf("\nThere were %d words.", words);
fclose(inp);
fclose(outp);
return(0);
}