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?
Printable View
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?
You can hide the console window with "ShowWindow(GetConsoleWindow(), SW_HIDE)" but that's only for Windows.
EDIT: By the way, where is KERALA???
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...
Use a If condition before the main body of the program and then make it true according to user's Choice..
Is there, any other way??
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.
@ salem
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!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");
}
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.
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 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.
The Pelles C compiler/IDE is FAR superior and up to date (and free). Highly recommended.
What you want to do, is already programmed into Windows XP, and imo, you should use that feature:
1) click start -->Control Panel -->Scheduled task -->Add scheduled task
2) When the wizard asks for the name of the program to run, enter mytimer.bat
3) Then create the mytimer.bat file, in the Windows/system32 directory (so it's in the path, and Windows can always find it).
4) open notepad and enter your shutdown command, into the bat file, and save it.
5) See if it works!
Personally, I would suggest getting the code::blocks IDE with the MinGW port of the GCC compiler.
Code::Blocks
Or visual studio express
Visual Studio2010 Express Editions |Microsoft Visual Studio
@Salem, is the MinGW port still supported?
MinGW is fine -> MinGW - Minimalist GNU for Windows - Browse Files at SourceForge.net
Perhaps you were thinking of the abandonware dev-c++ Bloodshed Software - Dev-C++ which hasn't been updated in the last 5 or 6 years.
So is the update cycle for the compiler.
I saw you moaning about pelles stability and bugs on another forum - which do you prefer, stability or bugs and frequent updates.
M$ come out with a new "20xx" every year or so if you like messing with new updates rather than getting down to some work.
Or if you want bleeding edge GCC, there's nothing to stop you either using Linux (in a VM if you're still not weaned off windows), or from porting GCC to windows yourself (for the adventurous).