Hi All,
Why when I complile and run the following:
#include "stdio.h"
main(void)
{
printf("test test test\n");
}
do I get no output to the screen? If I run it in the ddd debugger I get the
'test test test' in the console window, but when I run it from an Xterm get
nothing. Im wondering if stdout is set to somewhere else, but how do I check
this?
Regards
Michael 16 2810
Michael wrote: Hi All,
Why when I complile and run the following:
#include "stdio.h" main(void) { printf("test test test\n"); }
do I get no output to the screen? If I run it in the ddd debugger I get the 'test test test' in the console window, but when I run it from an Xterm get nothing. Im wondering if stdout is set to somewhere else, but how do I check this?
Your program should output "test test test" as you expect. The only
problem you have is that pre-C99 you need to return something from
`main()`. You don't tell what options you passed to your compiler and
what warnings, if any, you get.
Vladimir Oka wrote: Michael wrote: Hi All,
Why when I complile and run the following:
#include "stdio.h" main(void) { printf("test test test\n"); }
do I get no output to the screen? If I run it in the ddd debugger I get the 'test test test' in the console window, but when I run it from an Xterm get nothing. Im wondering if stdout is set to somewhere else, but how do I check this?
Your program should output "test test test" as you expect. The only problem you have is that pre-C99 you need to return something from `main()`. You don't tell what options you passed to your compiler and what warnings, if any, you get.
PS
You should also avoid implicit `int` when declaring `main()`. Spell it
out:
int main(void)
Hi Vladimir,
I just used:
gcc -g test.c -o test.exe
I get no warnings or errors
Thanks for your help.
Regards
Michael
"Vladimir Oka" <no****@btopenworld.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com... Michael wrote: Hi All,
Why when I complile and run the following:
#include "stdio.h" main(void) { printf("test test test\n"); }
do I get no output to the screen? If I run it in the ddd debugger I get the 'test test test' in the console window, but when I run it from an Xterm get nothing. Im wondering if stdout is set to somewhere else, but how do I check this?
Your program should output "test test test" as you expect. The only problem you have is that pre-C99 you need to return something from `main()`. You don't tell what options you passed to your compiler and what warnings, if any, you get.
"Michael" <mi*********@yahoo.com> wrote: Why when I complile and run the following:
#include "stdio.h" main(void) { printf("test test test\n"); }
do I get no output to the screen? If I run it in the ddd debugger I get the 'test test test' in the console window, but when I run it from an Xterm get nothing. Im wondering if stdout is set to somewhere else, but how do I check this?
You have a problem with your compiler setup. When I run this from the
compiler, I get a window that flashes on the screen and disappears
(which I can prevent by adding a command that makes it wait for input,
naturally); when I run it from a command line, it works as it should.
Ask in a newsgroup dedicated to your specific compiler suite or OS.
Richard
Michael wrote:
Your response belongs *under* the text you are replying to, after
deleting bits you are not replying to, not above. I've corrected it this
time. "Vladimir Oka" <no****@btopenworld.com> wrote in message news:11**********************@i40g2000cwc.googlegr oups.com... Michael wrote: Hi All,
Why when I complile and run the following:
#include "stdio.h" main(void) { printf("test test test\n"); }
do I get no output to the screen? If I run it in the ddd debugger I get the 'test test test' in the console window, but when I run it from an Xterm get nothing. Im wondering if stdout is set to somewhere else, but how do I check this? Your program should output "test test test" as you expect. The only problem you have is that pre-C99 you need to return something from `main()`. You don't tell what options you passed to your compiler and what warnings, if any, you get.
And, as you point out in another message, you should not use implicit
int ;-)
Hi Vladimir,
I just used: gcc -g test.c -o test.exe
I get no warnings or errors
OK, first off you are not doing enough to get all the useful warnings.
You should add -ansi -pedantic -Wall -O
Possibly -W as well, depending on your preferences.
Secondly, under C89 the compiler is not required to complain about
anything in your code (under C99, the latest standard not commonly
implemented the compiler is required to complain about the implicit
int), so the lack of warnings is not surprising.
<OT>
bash has a built in command called test so it will be running that
rather than your program. Just rename your program and it should work.
</OT>
PS, OT means Off Topic, i.e. if you want to discuss bash and its built
in test command further this is not the correct place.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro: http://clc-wiki.net/wiki/Intro_to_clc
Michael wrote: I just used: gcc -g test.c -o test.exe
Never name a test script or program "test" in any POSIX environment.
The shell builtin will usually be found first, and your program will
never be found.
Use "foo" for test programs. It's why the gods created that word.
Flash Gordon wrote: Michael wrote:
-snip- > Hi Vladimir, > > I just used: > gcc -g test.c -o test.exe > > I get no warnings or errors
OK, first off you are not doing enough to get all the useful warnings. You should add -ansi -pedantic -Wall -O Possibly -W as well, depending on your preferences.
I couldn't find any information on -W. I thought -Wall was the highest
warning level. What would -W do?
Best regards
Martin Jørgensen
--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Michael wrote: Hi Vladimir,
I just used: gcc -g test.c -o test.exe
I get no warnings or errors
Thanks for your help.
Don't top-post. Your replies belong following or interspersed with the
quotes.
As one person already mentioned, there is a progam called "test" on
most UNIX systems. Also, if you're running from the CYGWIN shell you
can't leave off the extension when you run it the way you can with
Windows or DOS. That's why progams developed on UNIX systems tend not
to have the .exe extension, as it doesn't mean (or do) anything special.
Brian
Martin Jørgensen wrote: Flash Gordon wrote: Michael wrote: -snip-
> Hi Vladimir, > > I just used: > gcc -g test.c -o test.exe > > I get no warnings or errors
OK, first off you are not doing enough to get all the useful warnings. You should add -ansi -pedantic -Wall -O Possibly -W as well, depending on your preferences.
I couldn't find any information on -W. I thought -Wall was the highest warning level. What would -W do?
It enables more warnings. Ask on one og the GNU gcc groups for more
information, such as gnu.gcc.help remembering to tell them what version
of gcc you are using.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro: http://clc-wiki.net/wiki/Intro_to_clc
Martin Jørgensen <un*********@spam.jay.net> writes: Flash Gordon wrote: Michael wrote: -snip-
> Hi Vladimir, > > I just used: > gcc -g test.c -o test.exe > > I get no warnings or errors OK, first off you are not doing enough to get all the useful warnings. You should add -ansi -pedantic -Wall -O Possibly -W as well, depending on your preferences.
I couldn't find any information on -W. I thought -Wall was the highest warning level. What would -W do?
<OT>
"info gcc" should show you the documentation for gcc, including
descriptions of all the command-line options.
</OT>
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Clever Monkey <cl**************@hotmail.com.invalid> writes: Michael wrote: I just used: gcc -g test.c -o test.exe Never name a test script or program "test" in any POSIX environment. The shell builtin will usually be found first, and your program will never be found.
Use "foo" for test programs. It's why the gods created that word.
<WAY_OT>
Better yet, never included "." (the current directory) in your $PATH.
If you want to execute a program in your current directory, always
type "./whatever".
</WAY_OT>
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Martin Jørgensen said: I couldn't find any information on -W. I thought -Wall was the highest warning level. What would -W do?
Not enough. Give yourself nightmares with -W -Wall -ansi -pedantic
-Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast
-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline
-Wundef -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
"Default User" <de***********@yahoo.com> writes: Michael wrote:
Hi Vladimir,
I just used: gcc -g test.c -o test.exe
I get no warnings or errors
Thanks for your help.
Don't top-post. Your replies belong following or interspersed with the quotes.
As one person already mentioned, there is a progam called "test" on most UNIX systems. Also, if you're running from the CYGWIN shell you can't leave off the extension when you run it the way you can with Windows or DOS. That's why progams developed on UNIX systems tend not to have the .exe extension, as it doesn't mean (or do) anything special.
<WAY_OT>
Cygwin runs under Windows, so executables always have names ending in
".exe". You can omit the extension when you execute the program;
Cygwin does some magic to let you refer to the file as either "foo" or
"foo.exe". If there's a shell script called "foo" and an executable
called "foo.exe", it resolves the ambiguity in some manner that I
can't be bothered to remember.
</WAY_OT>
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Keith Thompson wrote: "Default User" <de***********@yahoo.com> writes: As one person already mentioned, there is a progam called "test" on most UNIX systems. Also, if you're running from the CYGWIN shell you can't leave off the extension when you run it the way you can with Windows or DOS. That's why progams developed on UNIX systems tend not to have the .exe extension, as it doesn't mean (or do) anything special.
<WAY_OT> Cygwin runs under Windows, so executables always have names ending in ".exe". You can omit the extension when you execute the program; Cygwin does some magic to let you refer to the file as either "foo" or "foo.exe". If there's a shell script called "foo" and an executable called "foo.exe", it resolves the ambiguity in some manner that I can't be bothered to remember. </WAY_OT>
Ah. I thought it pretty much ran whatever shell it was, and the usual
Windows rules wouldn't come into play. I'm pretty sure it's at least
case-sensitive.
Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
"Default User" <de***********@yahoo.com> writes: [A cygwin question]
I'll reply to this by e-mail.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:ab************@news.flash-gordon.me.uk... Michael wrote:
Your response belongs *under* the text you are replying to, after deleting bits you are not replying to, not above. I've corrected it this time.
"Vladimir Oka" <no****@btopenworld.com> wrote in message news:11**********************@i40g2000cwc.googlegr oups.com... Michael wrote: Hi All,
Why when I complile and run the following:
#include "stdio.h" main(void) { printf("test test test\n"); }
do I get no output to the screen? If I run it in the ddd debugger I get the 'test test test' in the console window, but when I run it from an Xterm get nothing. Im wondering if stdout is set to somewhere else, but how do I check this? Your program should output "test test test" as you expect. The only problem you have is that pre-C99 you need to return something from `main()`. You don't tell what options you passed to your compiler and what warnings, if any, you get.
And, as you point out in another message, you should not use implicit int ;-)
Hi Vladimir,
I just used: gcc -g test.c -o test.exe
I get no warnings or errors
OK, first off you are not doing enough to get all the useful warnings. You should add -ansi -pedantic -Wall -O Possibly -W as well, depending on your preferences.
Secondly, under C89 the compiler is not required to complain about anything in your code (under C99, the latest standard not commonly implemented the compiler is required to complain about the implicit int), so the lack of warnings is not surprising.
<OT> bash has a built in command called test so it will be running that rather than your program. Just rename your program and it should work. </OT>
PS, OT means Off Topic, i.e. if you want to discuss bash and its built in test command further this is not the correct place. --
Thanks Guys, I knew it would be something really easy :-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dw |
last post by:
Pehaba,
does anyone knows how to install MySQLdb on cygwin?
- test device: MySQLdb 0.9.2.0 targz + cygwin
1.5.7-cr-0x9e + python
2.3.3 on cygwin + mysql
4.0.17 win32
- modified setup.py's...
|
by: Pekka Niiranen |
last post by:
Hi,
I started cygwin shell with command
subprocess.call("c:\\cygwin\\cygwin.bat")
from Python 2.4.
Shell works fine but the fonts/layout are
set according to program...
|
by: JustSomeGuy |
last post by:
I'm writing a socket class using unix flavor sockets. I'm developing on
win2k with M$ visual studio 6.0.
I have cygwin installed and would like to use its socket header files:
#ifdef UNIX...
|
by: alex |
last post by:
Hello
I have some c++ code, which has been happily developped in the
linux/unix world. Everything has always been compiled with different
compiler (intel, KAI, g++...) and gnu makefiles
For...
|
by: rihad |
last post by:
Hi, I have this problem: when reading a M$ Windows text file under Windows in
text mode (fopen("blah", "r")) the Windows newline sequence, \r\n is returned as
is, i.e. it's not replaced by a single...
|
by: lcw1964 |
last post by:
Greetings, all,
I am trying to port a little bit of math code to gcc, that in the
original version used the long double version of several functions (in
particular, atanl, fabsl, and expl).
I...
|
by: dot |
last post by:
I spent a few headache filled days trying to use GMP on windows
(XP pro)
I finally got it to work and since I found little help on the Web
I thought someone might find what i did useful.
...
|
by: Gotch |
last post by:
Hi all,
I've installed the CDT plugin for Eclipse and I want to use it to work
on C/C++ projects under Cygwin. It works, in fact it compiles and runs
the usual helloworld c++ program. Now it comes...
|
by: myusernotyours |
last post by:
Hi All,
Am working on a Java application in which I have to use the JNI to Interface with some native code for both windows and unix. Am using netbeans IDE with the C/C++ pack installed. Am also...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |