1
The file is written as follows:
palavra0palavra0palavra0
Since the words are different. The problem is to calculate the size of the largest word that appears between the zeroes, and the file can have any size.
I’ve been locked into the problem for days. I thought I’d calculate the amount of characters and put them in a string to then compare. The problem is being just compare the size of the words between the zeros to print the largest.
#include <stdio.h>
int main(void) {
char str[64];
scanf("%64s", str);
FILE *f= fopen(str, "r");
if(!f){
fprintf(stderr, "ERRO");
return 1;
}
char c;
//Calculo do tamanho do arq//
fseek(f, 0, SEEK_END);
long val1= ftell(f);
fseek(f,0,SEEK_SET);//
while((fscanf(f, "%c", &c)) != EOF){
if(c=='0'){
long y= ftell(f);
printf("%ld", y);
}
}
}