f



c compiler question (!GCC)

Hi,

I compiled the programme:

| #include <stdio.h>
|
| void* main()
| {
| int e=1;
| do {
| printf("\nEingabe: ");
| fflush(stdin);
| scanf("%d",&e);
| printf("\nEingabe war: %d",e);
| } while (e != 0);
| return;
| }

The result is:

> *test2
>
> Eingabe: 123
> 432
> 2435
> 7546
> 345
> 756
> 456
> 345
> 5
> 0
>
> Eingabe war: 123
> Eingabe:
> Eingabe war: 432
> Eingabe:
> Eingabe war: 2435
> Eingabe:
> Eingabe war: 7546
> Eingabe:
> Eingabe war: 345
> Eingabe:
> Eingabe war: 756
> Eingabe:
> Eingabe war: 456
> Eingabe:
> Eingabe war: 345
> Eingabe:
> Eingabe war: 5
> Eingabe:
> Eingabe war: 0*

The question I have is: why are all inputs taken before everything else
is printed on screen? I expected that it take one input, print one line,
take another input etc (this is what MS Visual Studio does).

Thank you for helping me to understand the !GCC compiler.

A.

-- 
Alexander Ausserstorfer, Bavaria
http://home.chiemgau-net.de/ausserstorfer/
0
1/1/2011 12:33:58 PM
comp.sys.acorn.programmer 2499 articles. 0 followers. Post Follow

2 Replies
407 Views

Similar Articles

[PageSpeed] 16

On Sat, 01 Jan 2011 13:33:58 +0100, "Alexander Ausserstorfer"
<bavariasound@chiemgau-net.de> wrote:

>Hi,
>
>I compiled the programme:
>
>[...]
>| fflush(stdin);
>[...]
>
>The question I have is: why are all inputs taken before everything else
>is printed on screen? I expected that it take one input, print one line,
>take another input etc (this is what MS Visual Studio does).

You need to flush stdout, not stdin.


John Kortink

-- 

Email    : kortink@inter.nl.net
Homepage : http://www.inter.nl.net/users/J.Kortink

Those who can, do. Those who can't, manage.

0
kortink (350)
1/1/2011 1:06:48 PM
On 1 Jan., 14:06, John Kortink <kort...@inter.nl.net> wrote:

> You need to flush stdout, not stdin.

Thanks. It's so nice and easy to use !GCC in combination with
StrongED!

A.


0
1/15/2011 7:22:05 AM
Reply:

Similar Artilces:

A !GCC-compiler question (C++)
Hello, using Microsoft Visual Studio following programme works properly: #include <iostream> using namespace std; void main() { cout << "Hello World!" << endl; } Using the GCC-compiler (4.1.1) for RISC OS doesn't work: *gcc cpp.test -o test test.cpp:1:20: error: iostream: No such file or directory test.cpp:3: error: '::main' must return 'int' test.cpp: In function 'int main()': test.cpp:5: error: 'cout' was not declared in this scope test.cpp:5: error: 'endl' was not declared in this scope Can me anybody give a shor...

C vs. C++ and C compiler optimization question
/* Consider the following C snippet: */ Foo *pFoo = NULL; void FooLength(Foo *pFoo); void FooHello(Foo **ppFoo); void FooWorld(Foo **ppFoo); void FooLength(Foo *pFoo) { int count = 0; for (Foo *p = pFoo; *p; p++) ++count; return count; } void FooHello(Foo **ppFoo) { int count = FooLength(*ppFoo); // ... } void FooWorld(Foo **ppFoo) { int count = FooLength(*ppFoo); // ... } // Consider the following C++ snippet: class FooHelloWorld { public: void FooHello(Foo **ppFoo) { iCount = FooLength(*ppFoo); // ... } void FooWorld(Foo *...

g++ compiled C++ code called from gcc compiled C code
Hi all! In a C library compiled with gcc there is a pointer to a function defined and called from within the library. Now I'm using that library in a C++ project and I'd like to set this function pointer to a C++ function. Do I have to set the C++ function __attribute__((cdecl)) ? Are there any other things I have to worry about? See example code below. Thanks very much, Klaus Example Code: ----------------------------------------------------- *** lib.c (compiled with gcc and linked to a library): void (* logfunc)(int,char*,...); int getSomething(void) { ... logf...

program that compiles in C compiler but not in C++ compiler
Hi, I need a small program that compiles in C compiler but not in C++ compiler. Thx in advans, Karthik Balaguru KBG <karthik.balaguru@lntinfotech.com> wrote: > I need a small program that compiles in C compiler but not in C++ > compiler. No problem, just send $10 to paypal@zevv.nl and I'll do your homework for you. -- :wq ^X^Cy^K^X^C^C^C^C KBG said: > Hi, > > I need a small program that compiles in C compiler but not in C++ > compiler. Can you think of any syntactic differences between C and C++? For example, what about keywords? They are very, very sen...

Are sun studio C/C++ compilers and Forte C/C++ compilers same ??
Is there any difference between sun studio compilers and forte compilers??? or the names have been changed??? In article <1145338052.955429.256610@v46g2000cwv.googlegroups.com>, "ameya_agnihotri" <ameyaagnihotri22@gmail.com> writes: > Is there any difference between sun studio compilers and forte > compilers??? > or the names have been changed??? One of many name changes in the product's history (including amongst others, Java somethingortheother, Workshop, Proworks/Teamworks, and probably more I've forgotten). Of course, the versions and features cha...

GCC C/C++ runtime library question
Hi, I am trying to replace the standard C and C++ libraries which comes with a Linux distro with our own(licensed from a 3rd party vendor). We will be providing the lower level layer which the C/C++ library uses(i.e. the system calls). What i would like to do is replace the standard and the runtime libraries which come with gcc with our own. I am a newbie in this and hence have some basic questions; 1. What is the exact difference between the C runtime and the C standard libraries i.e where does one end and the other begin; specifically w.r.t gcc? While i am going through a lot of text(both ...

c compilation
hello: I recently compiled a numerically intensive c project under cygwin gcc 3.4.4 and microsoft visual c. The platform is intel T2400 1.83 ghz dual core lap top. the numerical stuff is both floating point and integer intensive The gcc optimized (-O3) vs non optimized improved the performance 30 % visual c optimized (standard , check 'release; under visual c 2005) vs non optimized ('build') was a whopping 8x performance gain but the most surprising thing was visual c optimized was 2x performance over gcc optimized. is anybody else seeing the same thing. if this is true micro...

Question about comment parsing between C and C++ compiler
Hi, I am reading book <<Expert C Programming>>, it has the following quiz, a //* //*/ b In C and C++ compiler what does the above code trun out? I think it is simple for C compiler, it is a/b. But for C++ compiler, the book says it is a. The reason is "//" makes the rest of line comment. I am wondering on this. Just couple page back, it mentions that compiler has a "maximal munch strategy". For me when the C++ compiler reads the 1st line, there is ambiguous intepretation, it could be "a// *" or "a / /*", then if we apply...

Question about C semantics/optimizing C compilers
Hello all, we recently had some discussion about "Duff's Device" and which code a modern, optimizing compiler should produce for it. In case you never heard of "Duff's Device", you can read all about it here: <www.lysator.liu.se/c/duffs-device.html>. In short, the author of this code needed some efficient piece of code to write the contents of an array of "short"s to a video hardware register. Now, given the limitations of his C compiler at that time (1983!), he came up with the following amusing solution, which uses loop-unrolling in a very &qu...

require_once() question for PHP programmers with C or C++ background
I am trying to understand how require_once (generally including files in PHP) works. I understand the general concept - a bit similar to header files in C/C++, but I am a bit baffled by PHPs behaviour. I have two files (FILE 1 and FILE2): FILE1 ======== This file requires some constants defined in constants.php, as well as a classes defined in another file. file1 includes constants.php (via require_once()). This file then defines a class CLASS1. FILE2 ======== This second file needs a CLASS1 defined in FILE1, so I include FILE2 in FILE1 (again, via a require_once()). However, when I r...

RE: GCC C/C++ runtime library question
> I am trying to replace the standard C and C++ libraries which comes > with a Linux distro with our own(licensed from a 3rd party vendor). We > will be providing the lower level layer which the C/C++ library > uses(i.e. the system calls). What i would like to do is replace the > standard and the runtime libraries which come with gcc with our own. ... > 1. What is the exact difference between the C runtime and the C > standard libraries i.e where does one end and the other begin; > > 2. In a gcc distribution where exactly does the compiler specific > magic lie wi...

Advanced Test in C: The 0x10 Best Questions for C Programmers
Hi all, here is the link:- http://www.programmersheaven.com/articles/pathak/article2.htm http://www.programmersheaven.com/articles/pathak/article1.htm please go this site and ,rate & comment article On Sun, 04 Nov 2007 23:45:38 -0000, aarklon@gmail.com wrote in comp.lang.c: > Hi all, > > here is the link:- > http://www.programmersheaven.com/articles/pathak/article2.htm > http://www.programmersheaven.com/articles/pathak/article1.htm Rubbish. "Consider the data type * char is 1 byte * int is 2 byte * long int 4 byte * float is 4 byet (sic) * d...

Intel C/C++ compiler: two times faster then gcc!
Hello, First of all I tell you I'm speaking of the compilation time, and not of the execution time of the code generated! I'm making some experiments with the Intel C/C++ compiler for Linux (non commercial version). I compiled a qmake project of about 70 classes with both gcc and icpc: for the icpc compiler, I simply changed the lines: CC = gcc CXX = g++ LINK = g++ with: CC = icpc CXX = icpc LINK = icpc in the Makefile generated by qmake. Icpc said it didn't understand the -W and -fno-use-cxa-atexit, but was ab...

Manual for Acorn Desktop C (repost from c.s.a.programmer)
I've got one set of manuals - well I had the discs as well, but have disposed of them - for Acorn ANSI C release 4. I'm about to dispose of the manuals as well; unless somebody has a use for them. I'm after =A310 to cover carriage and handling. If nobody replies before 1pm, i'll be disposing of them via the trash... Dave ...

Web resources about - c compiler question (!GCC) - comp.sys.acorn.programmer

Compiler - Wikipedia, the free encyclopedia
... , or external linking . The most common reason for wanting to transform source code is to create an executable program. The name "compiler" ...

Compiler - Wikipedia, the free encyclopedia
"Compile" and "compiling" redirect here. For the software company, see Compile (publisher) . For other uses, see Compilation . This article has ...

Facebook Open-Sources HipHop PHP Compiler Software
Earlier this morning, Facebook officially made their new PHP “compiler,” called HipHop, available as open source software. In the blog post by ...

Art in the Age of Matter Compilers
jurvetson posted a photo: Sheba may be the harbinger of art in the digital age — a mathematical sculptor with digital matter. She manipulates ...

Interpreters and Compilers (Bits and Bytes, Episode 6) - YouTube
This animation explains the difference between interpreters and compilers. It is from Episode 6 of the classic 1983 television series, Bits and ...

Typesafe cofounder forking Scala compiler
The main contributor to the Scala compiler, Paul Phillips, has announced on GitHub that he is forking the compiler to “fix some of the innumerable ...

Does Apple's new developer agreement ban Adobe's Flash-to-iPhone compiler?
Given that any kind of formal truce between Apple and Adobe was essentially blown out of the water by Steve Job's very public slating of Flash ...

Apple seeds devs with Safari 5.2 for Lion, Xcode 4.4 with new LLVM compiler
... to the general public this summer. Among the new features: According to Apple, Xcode 4.4 includes an editor for Collada 3D files, compiler support ...

NVIDIA and Continuum Analytics Announce NumbaPro, A Python CUDA Compiler
... are announcing that they are bringing Python support to CUDA. Specifically, Continuum Analytics’ will be introducing a new Python CUDA compiler, ...

IntelliJ Releases IDEA 12, Brings Improved UI, New Compiler Mode, Android UI Designer, And More
I'm not going to pretend to be a developer here, and I'll openly admit that the bulk of what IDEA 12 does is over my head. However, I do understand ...

Resources last updated: 2/3/2016 3:37:37 PM