Problem with progress code
Code:
while(1) {
c = fgetc(fo);
if(c == EOF){
break;
}
else{
c = c + 'c' + 'd' - 't';
fputc(c,fw);
cnt++;
if(cnt % d == 0) {
prog++;
}
printf(" %d%%\r", prog);
fflush(stdout);
}
}
printf(" %d%%\n", prog);
printf("DONE!\n");
When the lines of code that are in red are removed, the program works very quickly, but when it's kept, it works extremely slowly.
This is part of a program that encrypts characters from a file and then outputs it into another file. I created this progress meter to show how long it takes when encrypting. When the file size is small, < 5kb, there is no problem. But when it's 3MB, then it takes upto 5 minutes when the progress meter is there, when I remove it, it takes only 5 seconds.
I don't see what the problem with the code is.