Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to use a struct in C to read in each word separately from a file to

ID: 3778533 • Letter: I

Question

I am trying to use a struct in C to read in each word separately from a file to then assign it to a pointer. With that I want to remove any puncuation and have each sentence separated when a period is found at the end of the sentence which uses a struct to keep track of the sentences to count how many sentences there are and how many words are in each sentence separately. So far I have:

#include <stdio.h>

#include <ctype.h>

int main(){

FILE *in = NULL;

char filename[20];

printf("Enter file name: ");

scanf("%s", filename);

in = fopen(filename,"r");

//checks for error opening the file

if(in == NULL)

{

printf("could not open file ");

return -1;

}

//scans in values of file sequencially

while(!feof(in)){

fscanf(in, "%s", );

}

fclose(in);

return 0;}

Explanation / Answer

Answer:

int main(){

FILE *in = NULL;

char filename[20];

int counts=1;. // count separate sentences

printf("Enter file name: ");

scanf("%s", filename);

in = fopen(filename,"r");

//checks for error opening the file

if(in == NULL)

{

printf("could not open file ");

return -1;

}

//scans in values of file sequencially

while(!feof(in)){

fscanf(in, "%s", );

}

while(ch!=fgetc(in))

{

if(ch=='.'){

counts++;

}

}

printf("number of separate sentences es is : %d",counts);

fclose(in);

return 0;}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote