Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Prob With My C Code
aks1232001
post Apr 14 2006, 05:51 AM
Post #1


Newbie
*

Group: Members
Posts: 3
Joined: 14-April 06
Member No.: 21,823



Hi Guys!

this is a wonderful place.. although i wasnt a member till now i have referred to these forms quite a few times for my programming solns biggrin.gif

My problem is :::

I am writing a Code in C using Bloodshed Dev C++ 4.9.9.2 on Windows XP. I wanted to open an executable file from my code. After using the solution mentioned on these forums, I used

QUOTE
system("myprg");


It works fine.. But the prob is that i want my C program to execute this command and then return to the next statement without waiting for me to close the program "mrprog.exe"..

Right now wat happens is suppose my code is:

QUOTE
system("myprog.exe");
printf("Hello World");


""Hello World" isnt printed on the screen till i exit the program myprog.exe

Is there any function that can do this job???
Kindly help me plz!

Thanx
Go to the top of the page
 
+Quote Post
WindAndWater
post Apr 14 2006, 06:57 AM
Post #2


Advanced Member
*******

Group: Members
Posts: 106
Joined: 1-April 06
Member No.: 21,148



As far as I know the only way to do what you want properly is to use threads and the fork and wait functions. Implimenting it is non-trivial, but if you really need to be able to do it, do a search for c, threads, and fork on google. You'll need to download an extra library and learn about interrupts. Alternatively, if you're running linux you might be able to get away with system("myprg &");
Go to the top of the page
 
+Quote Post
beeseven
post Apr 15 2006, 05:39 PM
Post #3


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



On Windows then you should be able to use the command "start." I'm not sure if it would work in this context, but it does in command prompt- usually if you start a program or batch file, it does the same thing that you're talking about, but start runs it independently. This is what I would do:
CODE
system("start /D. /B myprg");
/D. is the path, so if it's in a different directory, use /D"path to its directory"
/B says not to make a new window. If it's a text based thing then take that out.
Go to the top of the page
 
+Quote Post
aks1232001
post Apr 30 2006, 06:59 PM
Post #4


Newbie
*

Group: Members
Posts: 3
Joined: 14-April 06
Member No.: 21,823



Thanks a Zillion for the help guys smile.gif

I will try out ur instructions n tell u if it works..

I'm keeping my fingers crossed!!!
Go to the top of the page
 
+Quote Post
aks1232001
post Apr 30 2006, 07:34 PM
Post #5


Newbie
*

Group: Members
Posts: 3
Joined: 14-April 06
Member No.: 21,823



It works!!!!!!!!!!!!!!!!!!!!!!!! biggrin.gif

well i tried

QUOTE
system("start /D. /B myprg");


N it worked to perfection...
Thanks a lot Beeseven n Windandwater smile.gif



But there is a small new problem..
In my code written in C using Dev C++ created by Bloodshed (OS: Windows XP)
i want to access the serial ports.. I.e send data to them in order to control a motor that is connnected to my computer...

I know its easy to do that in win16 using turboC and function outportb()...but in win32 (i.e Dev C++) how do i do it???

I read some info on stuff like win API but a newbie like me found it really really confusing to do it..

are there any simples functions like outport() which i can use in my compiler???

Thanx a lot for all the help guys!

Eagerly awaiting ur reply biggrin.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How do you test your php code(77)
  2. Whats The Best Code?(32)
  3. Java Script Drop Down Menu With Css(2)
  4. Redirect Code Help(8)
  5. Da Vinci Code(16)
  6. Html Tag For A Code Box(4)
  7. Myspace Music Player(9)
  8. Simple C File Handling In Action(3)
  9. How To Make A Search Form And Php Code?(10)
  10. Wap Source Code Viewer(4)
  11. Rpg Code And Rpg Toolkit(10)
  12. Your First Autoit(4)
  13. Each And Every Nokia Code For Your Mobile(7)
  14. Error Code In Subscriptions Page(5)
  15. Runescape 2 Private Server: Code/guide 1(11)
  1. Html Code Tester. Online Script(15)
  2. How Do I Code A Design?(6)
  3. Php Code?(12)
  4. Mozilla: Firefox Plugin Shipped With Malicious Code(3)
  5. Malicious Code Injection(3)
  6. Php Source Code Unveiled In Browser?(7)
  7. Create Table - Mysql Code - Help(1)
  8. Why Doesn't This Code Work On Computinghost?(2)
  9. Add Flashing Inbox To Invisionfree Forum(2)
  10. Syntax Highlighting For Code(4)
  11. Davinci Code(4)
  12. Create Dynamic Html/php Pages Using Simple Vb.net Code(1)
  13. An Uncrackable Code!(1)


 



- Lo-Fi Version Time is now: 6th September 2008 - 07:46 PM