![]() |
| | #1 |
| Registered User Join Date: Jun 2009
Posts: 45
| Time in C++ Actually, the intention of this is to tar a file, and record the month and day somewhere, ideally in the name, but a hidden file would also work. Here's the program as it is now, no time function. Code: #include <iostream>
#include <stdlib.h> //For system()
using namespace std;
int main()
{
//Creates a hidden tarball in home.
system("tar -cvvf ~/.Record.tar Record/");
}
|
| Muscovy is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,862
| C++ appropriated most of the C standard library, and that was part of it. So change <time.h> to <ctime> and off you go. Notice that system requires a C-string, so you would have to build your command somewhere (a stringstream perhaps) and then convert it (with .str().c_str() or whatever) |
| tabstop is offline | |
| | #3 |
| Registered User Join Date: Jun 2009
Posts: 45
| I don't quite understand the second part. |
| Muscovy is offline | |
| | #4 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,862
| You want to do system(something) right? That something can't be a std::string, it has to be a C-string. But presumably you want to build it using all the power tools C++ gives you. So: Code: std::stringstream command; command << "tar -cvvf ~/."; command << month << day << "Record.tar Record/"; system(command.str().c_str()); |
| tabstop is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get current time | tsubasa | C Programming | 3 | 05-01-2009 02:03 AM |
| How to improve time performance of these operations | lehe | C Programming | 11 | 03-29-2009 12:27 PM |
| Help with assignment! | RVDFan85 | C++ Programming | 12 | 12-03-2006 12:46 AM |
| calculating user time and time elapsed | Neildadon | C++ Programming | 0 | 02-10-2003 06:00 PM |
| time class | Unregistered | C++ Programming | 1 | 12-11-2001 10:12 PM |