473,471 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

[Rookie] Date-Function, calling external files

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


Jul 19 '05 #1
1 3895
"Raskolnikow" <ra*********@freesurf.ch> wrote in message news:<bf************@ID-126543.news.uni-berlin.de>...
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,
<snip>
try {
proc = runtime.exec("command.com /c date " + targetDate);


It looks like you need the system() call in C and C++

Regards,
--
Michiel Salters
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: William S. Perrin | last post by:
I'm a python rookie, anyone have and suggestions to streamline this function? Thanks in advance..... def getdata(myurl): sock = urllib.urlopen(myurl) xmlSrc = sock.read() sock.close() ...
11
by: Don Bruder | last post by:
Got a stumper here. I imagine that for someone experienced in C++, this is too pathetic for words. For a rookie, using this project as a sort of "midterm exam" in his self-taught "how to program in...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
6
by: bigjmt | last post by:
Sorry to bother you guys with what I though would be an easy task. I have a table in my database were I would like one of the rows to increment a number for each row. I want the first row to start...
8
by: Tom | last post by:
Please help. I need a quick little scrpit to place on a web page that will count how many days have passed since January 1, 1970. I have ZERO experience writing ANY scripts. Anyone have any...
4
by: jtrecords | last post by:
I truly tried to get this one on my own... I am new to javascript, like 2 hours ago. So I'm messing with an example that inserts the current date in an html page. I want to keep the example and...
3
by: captain | last post by:
Below is the sql for data with same date need to extract + or - 5 days data of same date also. How to also get data of + and - days related to same date. SELECT IM.Area, IM.Location,...
2
by: Daveg | last post by:
Hello, Rookie here. I am new at c# and put together a script which is working fine grabbing some elements from an XML file that I created. The problem is that I would like to put at the top of...
0
by: EZboy | last post by:
Rookie question ..... can anybody please send me a sample code that illustrates : how to display an mpg video clip on a new window that is being opened from within an application ? Many Thanks,...
3
by: Dst | last post by:
Hi i'm trying to make a very simple web site using visual studio 2005. I'm completely noob at this so i need some pointers to get me started. As i understand frames should not be used in...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.