Hi, the issue lies with your code: you're using carriage returns (\r,
AKA CR), which will make your terminal move the "cursor" to the
beginning of the line *without shifting lines*, thus overwriting the
previous output. Inserting a sleep() right before that last printf()
will show you the effects. You probably wanted a line feed character
instead (\n, AKA LF).

The fact that you could see the output when there was an error was
because the error path bypasses that call. Even if it didn't, it would
still have worked because it ends with a LF, so the carriage return
would operate on the new line rather than the current one.

Note that line-ending behaviors are platform-specific. I wouldn't be
surprised if Apple platforms would interpret the CR as CR+LF for
compatibility with older Mac programs for instance.

** Changed in: gcc-11 (Ubuntu)
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2119376

Title:
  program starts with printf("a");fflush(stdout);yet doesnt echo
  anything

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-11/+bug/2119376/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to