where does cc send the output by default

G

Greenhorn

Hi,
when i run the output file generated by using cc i get no output on
my terminal.

#include <stdio.h>
main()
{
printf("Testing the printf functionality");

}
Terminal screen:

[...@localhost ~]$ cc test.c
[...@localhost ~]$ test
[...@localhost ~]$


where do u think the output is going. How should i redirect to the
terminal

greenhorn
 
W

Walter Roberson

: when i run the output file generated by using cc i get no output on
:my terminal.

:[...@localhost ~]$ cc test.c
:[...@localhost ~]$ test

: where do u think the output is going. How should i redirect to the
:terminal

'test' is a built-in unix shell command. You are not running your
program. Try running ./test instead of test

Also, it is fairly common for C compilers to compile to a name such
as a.out if you do not explicitly tell the compiler otherwise.
Commonly, this would be by way of the '-o' option, as in

cc -o test test.c
../test
 
A

Artie Gold

Greenhorn said:
Hi,
when i run the output file generated by using cc i get no output on
my terminal.

#include <stdio.h>
main()
{
printf("Testing the printf functionality"); fflush(stdout);

}
Terminal screen:

[...@localhost ~]$ cc test.c
[...@localhost ~]$ test
[...@localhost ~]$


where do u think the output is going. How should i redirect to the
terminal

greenhorn
....but that's not the problem.
<OT>
You haven't run your program at all. Try "./test".
Ask your question at for more information.
</OT>

HTH,
--ag
 
A

Artie Gold

Artie said:
Greenhorn said:
Hi,
when i run the output file generated by using cc i get no output on
my terminal.

#include <stdio.h>
main()
{
printf("Testing the printf functionality");
fflush(stdout);


}
Terminal screen:

[...@localhost ~]$ cc test.c
[...@localhost ~]$ test
[...@localhost ~]$


where do u think the output is going. How should i redirect to the
terminal

greenhorn
...but that's not the problem.
<OT>
You haven't run your program at all. <oops>Try "./test"</oops>*.
Ask your question at for more information.
</OT>

HTH,
--ag
*seee Walter's post
 
D

DHOLLINGSWORTH2

Greenhorn said:
Hi,
when i run the output file generated by using cc i get no output on
my terminal.

#include <stdio.h>
main()
{
printf("Testing the printf functionality");

}
Terminal screen:

[...@localhost ~]$ cc test.c
[...@localhost ~]$ test
[...@localhost ~]$


where do u think the output is going. How should i redirect to the
terminal

greenhorn
The output buffer, which is lost at exit. Try adding "/n" to the end of
your print statement, or add flushall() before the program terminates.
 
K

Keith Thompson

DHOLLINGSWORTH2 said:
Greenhorn said:
Hi,
when i run the output file generated by using cc i get no output on
my terminal.

#include <stdio.h>
main()
{
printf("Testing the printf functionality");

}
Terminal screen:

[...@localhost ~]$ cc test.c
[...@localhost ~]$ test
[...@localhost ~]$


where do u think the output is going. How should i redirect to the
terminal

greenhorn
The output buffer, which is lost at exit. Try adding "/n" to the end of
your print statement, or add flushall() before the program terminates.

You mean "\n", not "/n". There is no flushall() in standard C; you
probably mean fflush(stdout) (which still doesn't guarantee that the
output isn't, for example, overwritten by the prompt after the program
terminates). (You can flush all appropriate streams with
fflush(NULL), but that's not necessary in this case.)

But in fact that's probably not the problem the OP is running into.
Judging by the prompt, the OP appears to be using some Unix-like
system. The actual problem has to do with the name of the default
output file created by the compiler; don't assume that it's related to
the name of the source file, or that the name "test" is not otherwise
meaningful. The details are off-topic here.

Also, main should be declared to return an int, preferably as
"int main(void)", and there should be a "return 0;" (not required in
C99, and not strictly required even in C90, but still a good idea).
 
H

Hue-Bond

Walter Roberson, jue20050224@23:52:37(CET):
cc -o test test.c

If make is installed, it can be used without a Makefile just with 'make
test'. Plus, it honors CFLAGS.

$ cat > foo.c
int main() { printf ("bar\n"); return 0; }
$ make foo
cc -mcpu=pentium -march=pentium -O3 -pipe -fomit-frame-pointer -funroll-loops
foo.c -o foo
$ ./foo
bar
 
W

Walter Roberson

:> cc -o test test.c

:If make is installed, it can be used without a Makefile just with 'make
:test'.

'make' is not a good candidate for discussion in comp.lang.c .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top