2
I have to count the number of characters and line breaks in my file.I did it this way:
The idea is to count the line break every time someone gives enter, but I can only use the getc
.
include <stdio.h>
include <stdlib.h>
int main(void) {
int cont = 0;
int contlinha = 0;
while (getc(stdin) != EOF) {
cont++;
if (getc(stdin) == '\n') {
contlinha++;
}
}
printf("Caracteres: %d new lines: %d\n", cont, contlinha);
system("pause");
return 0;
}
However this code returns me wrong numbers, and on top of that Z does not come out directly when I open in cmd
. What’s wrong? I can’t see what doesn’t work.
can you answer my question? https://answall.com/questions/469237/identificar-registrations-sequentialof each user
– JavaScript