0
Good evening, I have a question, I have a program that will receive several files of the type nome.txt
, and I must count how many characters are inside the file, I tried to make a prototype but doubt is on how I will add it using getline
and using file pointers?? I mean, how do I get files in txt and then check the characters??
Below is the code:
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int counter = 0;
FILE* file = NULL;
char * arquivo = NULL;
char frases;
size_t aux = 0;
getline(&arquivo,&aux, stdin);
file = fopen("arquivo", "r" );
while(fgetc(file) != EOF)
counter++;
printf("%d", counter);
fclose(file);
}
I didn’t quite understand the question. What’s going wrong in your program? What was the result you were hoping for?
– hugomg