![]() |
system(); under Cygwin
Hi all, im trying to use system(); with Cygwin but its not working...
look my code; ------------- #include <stdlib.h> int main(void) { printf("test"); system("dir"); return 0; } ------------- I'm doing gcc test.c -o test.exe and im running test.exe under Windows with cygwin1.dll ! Thanks -my email is fr4nck@cgocable.ca |
Re: system(); under Cygwin
In 'comp.lang.c', fr4nck@cgocable.ca (Framcl) wrote:
> Hi all, im trying to use system(); with Cygwin but its not working... > > look my code; > ------------- Well, it could be better! > #include <stdlib.h> #include <stdio.h> > int main(void) > { > printf("test"); printf("test\n"); > system("dir"); > return 0; > } > ------------- > > I'm doing gcc test.c -o test.exe Too weak! gcc -W -Wall -ansi -pedantic -O2 test.c -o test.exe > and im running test.exe under Windows with cygwin1.dll ! What do you mean by 'it doesn't work'? Maybe it's just because the console blinks and that you have no time to see the results. Add this at the end of the main() (just before the 'return') : system ("pause"); or getchar(); -- -ed- emdelYOURBRA@noos.fr [remove YOURBRA before answering me] The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html <blank line> FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/ |
Re: system(); under Cygwin
On 8 Aug 2003 06:13:15 GMT
Emmanuel Delahaye <emdelYOURBRA@noos.fr> wrote: > In 'comp.lang.c', fr4nck@cgocable.ca (Framcl) wrote: > > > Hi all, im trying to use system(); with Cygwin but its not > > working... > > > > look my code; > > ------------- > > Well, it could be better! > > > #include <stdlib.h> > > #include <stdio.h> > > > int main(void) > > { > > printf("test"); > > printf("test\n"); > > > system("dir"); > > return 0; > > } > > ------------- > > > > I'm doing gcc test.c -o test.exe > > Too weak! > > gcc -W -Wall -ansi -pedantic -O2 test.c -o test.exe Also don't use test as a program name, especially if you are running the executable from within bash. > > and im running test.exe under Windows with cygwin1.dll ! > > What do you mean by 'it doesn't work'? Maybe it's just because the > console blinks and that you have no time to see the results. Add this > at the end of the main() (just before the 'return') : > > system ("pause"); > or > getchar(); If it's being run from Windows directly rather than from within a Cygwin bash shell then the OP also needs to wander over to a Cygwin mailing list or news group. -- Mark Gordon |
Re: system(); under Cygwin
On 7 Aug 2003 22:04:52 -0700, fr4nck@cgocable.ca (Framcl) wrote:
>Hi all, im trying to use system(); with Cygwin but its not working... > >look my code; >------------- >#include <stdlib.h> > >int main(void) >{ >printf("test"); >system("dir"); >return 0; >} >------------- > >I'm doing gcc test.c -o test.exe > >and im running test.exe under Windows with cygwin1.dll ! > >Thanks >-my email is fr4nck@cgocable.ca Try naming it something else. "test" is a magic name under some Unix shells. -- Al Balmer Balmer Consulting removebalmerconsultingthis@att.net |
Re: system(); under Cygwin
On Thu, 07 Aug 2003 22:04:52 -0700, Framcl wrote:
> Hi all, im trying to use system(); with Cygwin but its not working... > > look my code; > ------------- > #include <stdlib.h> > > int main(void) > { > printf("test"); This may not display anything. Use: printf("test\n"); Or: printf("test"); fflush(stdout); > system("dir"); The exact behaviour of system("dir") is implementation-defined. <ot>Try system("ls"), since you're using cygwin</ot> > return 0; > } > ------------- > > I'm doing gcc test.c -o test.exe > > and im running test.exe under Windows with cygwin1.dll ! > > Thanks > -my email is fr4nck@cgocable.ca -- Freenet distribution not available There is one difference between a tax collector and a taxidermist -- the taxidermist leaves the hide. -- Mortimer Caplan |
Re: system(); under Cygwin
Groovy hepcat bd was jivin' on Fri, 08 Aug 2003 14:41:23 -0400 in
comp.lang.c. Re: system(); under Cygwin's a cool scene! Dig it! >On Thu, 07 Aug 2003 22:04:52 -0700, Framcl wrote: > >> Hi all, im trying to use system(); with Cygwin but its not working... >> >> look my code; >> ------------- >> #include <stdlib.h> >> >> int main(void) >> { >> printf("test"); > >This may not display anything. Use: Wrong. It must display something. The problem is *when* it is displayed is unknown. >printf("test\n"); >Or: >printf("test"); >fflush(stdout); It is better, in this case, to use the former option. It is implementation defined whether the last line on a text stream requires a terminating newline. So be safe and put a newline at the end of the output. -- Dig the even newer still, yet more improved, sig! http://alphalink.com.au/~phaywood/ "Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker. I know it's not "technically correct" English; but since when was rock & roll "technically correct"? |
Re: system(); under Cygwin
On Tue, 12 Aug 2003 00:23:47 GMT,
Peter "Shaggy" Haywood <phaywood@alphalink.com.au.STOP.SPAM> wrote: >Groovy hepcat bd was jivin' on Fri, 08 Aug 2003 14:41:23 -0400 in >comp.lang.c. > >>printf("test\n"); >>Or: >>printf("test"); >>fflush(stdout); > > It is better, in this case, to use the former option. It is >implementation defined whether the last line on a text stream requires >a terminating newline. So be safe and put a newline at the end of the >output. > It has occurred that people don't see the output from the latter option because the next shell prompt promptly overwrote it. This has led to a very frustrating search for a non-existing bug. Terminating the text with a new line will force the screen display to scroll before the next shell prompt. Villy |
Re: system(); under Cygwin
Originally posted by Framcl > Hi all, im trying to use system(); with Cygwin but its not working... > > look my code; > ------------- > #include <stdlib.h> > > int main(void) > { > printf("test"); > system("dir"); > return 0; > } > ------------- > > I'm doing gcc test.c -o test.exe > > and im running test.exe under Windows with cygwin1.dll ! > > Thanks > -my email is fr4nck@cgocable.ca I Have the SAME problem, i discovered it with two winshit systems I had win95c and win200 and put this: int main(int ac,char **av) { system("/bin/sleep 60"); } just to prove it it works under win200, but it compiles on win95c, but doesnt work system on win95c never runs that command with system () I don't know wtf is going on. It's the same cygwin on both os, but it someone can help, thanks a lot I need that function on both os's -- Posted via http://dbforums.com |
| All times are GMT. The time now is 02:54 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.