I am trying to use a struct in C to read in each word separa

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;}

Solution

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;}

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
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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site