R
Raskolnikow
Hi!
I have some beginner questions about C++,
so please be gentle if the things I ask are trivial.
What I want to do is a program that
- changes the current (system) date,
- calls an external program and
- resets the system date again (after a delay).
I have just written that in Java, but I wanted it to
be a small and nice tool (i.e. without loading the VM)
in C or C++.
Unfortunately I have only Borland C++ 5.5 and
TurboC 2.0. Which compiler options can I use to
make the executable as small as possible ?
So here is an excerpt from my java prog:
public final class DateChange {
private static Process proc;
public static void main(String[] args) {
if (args == null || args.length < 2) {
System.out.println("SYNTAX: DateChange <FileName> <Date>");
System.exit(1);
}
String command = args[0];
String targetDate = args[1];
Date date = new Date();
String currentDate = date.toLocaleString().substring(0,10); // this is
DD/MM/YYYY
Runtime runtime = Runtime.getRuntime();
try {
proc = runtime.exec("command.com /c date " + targetDate);
proc = runtime.exec(command);
// waiting for the program to start up
Thread.sleep(5000);
proc = runtime.exec("command.com /c date " + currentDate);
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
System.exit(0);
}
}
Thanks a lot !
Cheers,
Bernhard
I have some beginner questions about C++,
so please be gentle if the things I ask are trivial.
What I want to do is a program that
- changes the current (system) date,
- calls an external program and
- resets the system date again (after a delay).
I have just written that in Java, but I wanted it to
be a small and nice tool (i.e. without loading the VM)
in C or C++.
Unfortunately I have only Borland C++ 5.5 and
TurboC 2.0. Which compiler options can I use to
make the executable as small as possible ?
So here is an excerpt from my java prog:
public final class DateChange {
private static Process proc;
public static void main(String[] args) {
if (args == null || args.length < 2) {
System.out.println("SYNTAX: DateChange <FileName> <Date>");
System.exit(1);
}
String command = args[0];
String targetDate = args[1];
Date date = new Date();
String currentDate = date.toLocaleString().substring(0,10); // this is
DD/MM/YYYY
Runtime runtime = Runtime.getRuntime();
try {
proc = runtime.exec("command.com /c date " + targetDate);
proc = runtime.exec(command);
// waiting for the program to start up
Thread.sleep(5000);
proc = runtime.exec("command.com /c date " + currentDate);
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
System.exit(0);
}
}
Thanks a lot !
Cheers,
Bernhard