RE: [C] Loading Animation 06-22-2014, 10:13 PM
#6
Sorry, I didn't see your point before.
Even through the debugger, the string is printed only at the end of the execution (when stdout is used).
That function is "compute the matrix product between A and B for 100 times, where A and B are both 100x100" (naive algorithm, no optimization, takes some milliseconds).
Now, I'm really curious to understand why this happens...
(06-22-2014, 09:04 PM)ArkPhaze Wrote: If it didn't work then you're doing something wrong, because stderr is WRONG. stdout is proper... Did you test this through a debugger or actually run the program?First I run it, using stdout; I saw it didn't work, so I tried through a debugger (gdb). Then I repeated using stderr.
Even through the debugger, the string is printed only at the end of the execution (when stdout is used).
(06-22-2014, 09:04 PM)ArkPhaze Wrote: I haven't tested how the carriage return works on a Unix system, I'd imagine it would be fine as long as the developers define the beginning of a line the same as in Windows or at least close enough to the same...I think this is the case... otherwise the version using stderr wouldn't work at all, would it?
(06-22-2014, 09:04 PM)ArkPhaze Wrote: The issue is the Sleep() function; being a Windows only function in this case.[...]I'm not sure: I tried to implement a CPU-eating function, without using "sleep" or any other thread/time function. Once again, it works using stderr but not with stdout.
That function is "compute the matrix product between A and B for 100 times, where A and B are both 100x100" (naive algorithm, no optimization, takes some milliseconds).
Now, I'm really curious to understand why this happens...
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)