User forums > Using Code::Blocks

Strange output in CodeBlocks with gcc in Windows

(1/2) > >>

jimshen:
I use CB in windows and the compiler is gcc. When I build and run the program below, I found the result is strange. Can anyone give me an explain?

#include <stdio.h>
int main()
{
    int a=5,b=6,c=7;
    printf("%d\n%d %d\n %d %d\t\b%d\n",a,b,c,a,b,c);
    printf("%d %d\t\b%d\n",a,b,c);
    return 0;
}

The result is:

5
6 7
75 6
5 67

I tried DevC++ which use MinGW as compiler and got same result. It seems that is the problem of MinGW.


The result should be (When use Turbo C in DOS or gcc in Linux)
5
6 7
5 6  7
5 6   7

Michael:
Hmmm, what about the \b?

Best wishes,
Michael

jimshen:

--- Quote from: Michael on March 06, 2006, 01:14:29 pm ---Hmmm, what about the \b?

Best wishes,
Michael


--- End quote ---

\b and \t.

Michael:

--- Quote from: jimshen on March 06, 2006, 01:18:01 pm ---\b is backspace escape character

--- End quote ---

Ah yes. Thanks :). I have found in google too (was not so easy though). I never use it anyway.

AFAIK, the output of the second printf is correct. You do a \t and then a \b.

Best wishes,
Michael

jimshen:

--- Quote from: Michael on March 06, 2006, 01:32:47 pm ---Ah yes. Thanks :). I have found in google too (was not so easy though). I never use it anyway.

AFAIK, the output of the second printf is correct. You do a \t and then a \b.

Best wishes,
Michael


--- End quote ---

The result is not same as the result in linux. Please see the first message I modified.

Navigation

[0] Message Index

[#] Next page

Go to full version