running in background

This is a discussion on running in background within the C Programming forums, part of the General Programming Boards category; hi frnz, i want to create an exe (using c) which first, gets users' choice and then runs in background. ...

  1. #1
    Registered User krishnapollu's Avatar
    Join Date
    Dec 2010
    Location
    KERALA
    Posts
    29

    running in background

    hi frnz,

    i want to create an exe (using c) which first, gets users' choice and then runs in background. i am using TCC compiler. and my os is xp.

    can anyone pls suggest a solution?

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,602
    You can hide the console window with "ShowWindow(GetConsoleWindow(), SW_HIDE)" but that's only for Windows.

    EDIT: By the way, where is KERALA???
    Devoted my life to programming...

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,334
    Well it's tough to write a program in an emulated environment which can actually do anything significant to the host.

    Stop mucking about with TurbidCrap on XP.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Salem View Post
    Well it's tough to write a program in an emulated environment which can actually do anything significant to the host.

    Stop mucking about with TurbidCrap on XP.
    Actually Salem... TCC probably refers to the TinyC compiler...

  5. #5
    Registered User
    Join Date
    Dec 2010
    Location
    Lucknow, India
    Posts
    72
    Use a If condition before the main body of the program and then make it true according to user's Choice..

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Gaurav Singh View Post
    Use a If condition before the main body of the program and then make it true according to user's Choice..
    You can't put code outside of a function in C... it won't compile.

  7. #7
    Registered User krishnapollu's Avatar
    Join Date
    Dec 2010
    Location
    KERALA
    Posts
    29

    Unhappy

    Is there, any other way??

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,334
    Try posting some of the code you're working with, so we can see what it is you're trying to do.

    One-line posts vaguely describing the problem are not going to cut it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User krishnapollu's Avatar
    Join Date
    Dec 2010
    Location
    KERALA
    Posts
    29
    @ salem

    Code:
    
    #include<stdio.h>
    #include<conio.h>
    #include<time.h>
    
    void main()
    {
    	int hr,min,flag=0;
    	struct time t;
    
    	printf("Enter the time: ");
    	printf("\n\tHours: ");
    	scanf("%d",&hr);
    	printf("\n\tMinutes: ");
    	scanf("%d",&min);
    
    	do
    	{
    		gettime(&t);
    		if(t.ti_hr==hr&&t.ti_min==min)
    			flag=1;
    	}while(flag);
    
    	system("c:\\windows\\system32\\shutdown -s");
    }
    since it requires a long time for the flag to become 1, i want to put the program in background. This is the problem i hav!

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,334
    So I take it from the conio.h and void main that you are in fact using the 20+ year old FOSSIL compiler Turbo C Compiler (TCC) and not the modern TinyCCompiler that CommonTater linked to.

    Just because you managed to get "hello world" to work with it does NOT make it suitable for every other programming task you might have.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    Registered User krishnapollu's Avatar
    Join Date
    Dec 2010
    Location
    KERALA
    Posts
    29
    Quote Originally Posted by Salem View Post
    So I take it from the conio.h and void main that you are in fact using the 20+ year old FOSSIL compiler Turbo C Compiler (TCC) and not the modern TinyCCompiler that CommonTater linked to.

    Just because you managed to get "hello world" to work with it does NOT make it suitable for every other programming task you might have.
    so are u tryin to say that it isn't possible using my type of compiler???

  12. #12
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,334
    You'd have to ask Adak, he's the only TC fan still left on this forum.
    Most other people no longer care about answering TC questions, even if they know the answer.

    Try getting a modern compiler for your real OS and try the same code again (with int main, and NO conio.h).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  13. #13
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by krishnapollu View Post
    so are u tryin to say that it isn't possible using my type of compiler???
    If you are using Borland's Turbo C compiler a lot of stuff is --or soon will be-- impossible...
    Turbo C is a 16 bit compiler, made for pre-iapx386 computers. Most computers are now 32/64 bit compatible and the slow migration to 64 bit OSs is underway. 64 bit Windows OSs do not support 16 bit programs anymore. If you are not working with at least a 32 bit compiler you will soon find yourself writing code that only works on old computers. And with 128bit machines already in the planning stages it won't be long until 32 bit systems suffer a similar fate.

    For your problem of making your timer run in the background... just click the "minimize" icon on the upper right corner of the command shell... It will be minimized to the task bar where it's out of the way.

  14. #14
    Registered User krishnapollu's Avatar
    Join Date
    Dec 2010
    Location
    KERALA
    Posts
    29
    Quote Originally Posted by CommonTater View Post
    If you are using Borland's Turbo C compiler a lot of stuff is --or soon will be-- impossible...
    Turbo C is a 16 bit compiler, made for pre-iapx386 computers. Most computers are now 32/64 bit compatible and the slow migration to 64 bit OSs is underway. 64 bit Windows OSs do not support 16 bit programs anymore. If you are not working with at least a 32 bit compiler you will soon find yourself writing code that only works on old computers. And with 128bit machines already in the planning stages it won't be long until 32 bit systems suffer a similar fate.

    For your problem of making your timer run in the background... just click the "minimize" icon on the upper right corner of the command shell... It will be minimized to the task bar where it's out of the way.
    thanks..
    actually these are fresh news to me.
    once again i thank you!!

    one more thing!
    can u suggest me a compiler which may help ma purpose?
    Last edited by krishnapollu; 02-28-2011 at 07:30 AM.

  15. #15
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My own terminal > Running a background process
    By tiestodj in forum C Programming
    Replies: 3
    Last Post: 03-06-2010, 02:30 AM
  2. background jobs running inside a bash script
    By lehe in forum Linux Programming
    Replies: 8
    Last Post: 08-02-2009, 04:40 PM
  3. Running my program in the background
    By shoobsie in forum Windows Programming
    Replies: 4
    Last Post: 10-09-2005, 02:38 AM
  4. Running A Routine in the background
    By smegly in forum C Programming
    Replies: 4
    Last Post: 05-16-2004, 06:42 PM
  5. Running program on background?
    By Couhilin in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2001, 06:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21