is there a way to run a program using C?
i tried to open an exe file - that just messed it up //good thing it wasnt important
thanks
is there a way to run a program using C?
i tried to open an exe file - that just messed it up //good thing it wasnt important
thanks
your question seems vague.
Are you using any IDEs? (Example: Code::Blocks,Visual Studio,Turbo C,...)
What compiler are you using?
How did you try to open the executable file?
Last edited by stevesmithx; 12-14-2008 at 02:41 PM.
Not everything that can be counted counts, and not everything that counts can be counted
- Albert Einstein.
No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
- Herbert Mayer
There are several ways for a C program to call an .exe program.
There are exec...() functions, spawn...() functions, and the system() function. Maybe others too.
Mainframe assembler programmer by trade. C coder when I can.
i was looking it up and found:
system("programname"); // that worked if i put the program in my BIN folder.
i am using Borland 5.02 compiler.
when i called the program, another c program i made, it ran in the same dos window the other was currently running in.
the next thing i wanna know is - how to open this program in a new window dos window
any ideas?
Thanks for the replies
You might want to use a new compiler.i am using Borland 5.02 compiler
In that case you might want to use:when i called the program, another c program i made, it ran in the same dos window the other was currently running in.
the next thing i wanna know is - how to open this program in a new window dos window
You might also want to use:Code:system("start program_name");
in your called program to prevent the command prompt from closing immediately after execution of the program.Code:system("pause")
Anyway,It is NOT recommended to use this method.
See the faq:
http://faq.cprogramming.com/cgi-bin/...&id=1043284392
Not everything that can be counted counts, and not everything that counts can be counted
- Albert Einstein.
No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
- Herbert Mayer
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
I use a 1987 program called Lets C C Compiler. I now use visual studio, but anyway if your running a DOS program on windows if your program exits as soon as you start it right click and go to program on the tabs and unselect close on exit. then try it if that doesnt work I dont know but its worth a try thats how I get my c programs to run. And to launch it use the command CD and then the location, and then enter the name of you program but I normally navigate to the location useing windows explorer and double click the Icon and it opens up in a command prompt.
Last edited by C-Compiler; 12-15-2008 at 06:19 PM.
I program using Visual Studio Professional 2008. I have little experience, I'm self taught. I started basic C in early March 2008 with a 1987 compiler and C++ this October with Visual Studio. I normally program in Visual C++ creating form programs. My current project is a simple game where I hide a dot and you have to find it in different random sinerios.
My Catchphrase:
DOS wasn't written in a day...
anyone wants to point me to a better compiler - thanks mucho.
my sytem is
4Gig ram
intel duo.
Vista Home
AND THANKS FOR ALL THE HELP AND REPLIES!! XD
this is what i tried for the "start program_name" method - cmd reported that they cant find the file.Code:# include <conio.h> # include <stdlib.h> # include <stdio.h> void main () { printf ("Press any key to call the program\n\n"); getch(); system ("start prgram.bat"); system("pause"); printf ("\n\nPress any key to continue"); getch(); }
props to you man!!!
i got the second dos window opened - but it pops up and goes behind the current one.
what i am tryin to create is a pop up window effects, like "windows" - u choose an option and a new program, window, runs and when its closed it goes back to the original window.
Thank for the help guys.
Never use system()
Use Win32 api.
Download GCC, which for windows you find as MinGW. Or download Visual Studio, which is a debugger/IDE/compiler all together.
You can create a "normal" window, not a shell with CreateWindow() or CreateWindowEX() functions using the win api. Google it.
But all depends on what you want to do with the new windows. If you want to pop up messages then win api is really what you want. If you indeed want a new shell then system(), spawn() etc etc is a quick solution
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010