Create a timer
-
Good Morning everybody. I'm developing a program in C++. It is supposed that the program has to read from excel and write the data in a .txt file. It has to do that during 10 minutes, and after that save the .txt and start doing it again. How can I do the timer? May you help me please? The program I write is this one: (Not sure if is correct)
#include
#include
#include
#include
#include
#includeusing namespace std;
struct vehiculo
{
char VIN[8]
char hora[19]
};
int main()
vehiculo cocheentrante
{
File *F;
File *G;//Abrir archivo de Excel F = fopen("C:\\Users\\Ford\\Usuarios\\Cristales\\VINES.csv", "rt"); if (F == NULL) { cout << "No se pudo abrir el archivo de entrada. \\n"; } else { cout << "El archivo se abrio correctamente. \\n"; } //Crear archivo txt G = fopen("dd\_mm\_aaaa\_\_hh\_mm\_ss.txt","w"); if((G = fopen("dd\_mm\_aaaa\_\_hh\_mm\_ss.txt","w"))!= NULL) { //Leer archivo de excel while(!feof(F)) { fgets(VIN,8,F); fgets(hora,19,F); fprintf(G, "%s %s", &VIN, &hora); } } fclose(G); fclose(F);
}
-
Good Morning everybody. I'm developing a program in C++. It is supposed that the program has to read from excel and write the data in a .txt file. It has to do that during 10 minutes, and after that save the .txt and start doing it again. How can I do the timer? May you help me please? The program I write is this one: (Not sure if is correct)
#include
#include
#include
#include
#include
#includeusing namespace std;
struct vehiculo
{
char VIN[8]
char hora[19]
};
int main()
vehiculo cocheentrante
{
File *F;
File *G;//Abrir archivo de Excel F = fopen("C:\\Users\\Ford\\Usuarios\\Cristales\\VINES.csv", "rt"); if (F == NULL) { cout << "No se pudo abrir el archivo de entrada. \\n"; } else { cout << "El archivo se abrio correctamente. \\n"; } //Crear archivo txt G = fopen("dd\_mm\_aaaa\_\_hh\_mm\_ss.txt","w"); if((G = fopen("dd\_mm\_aaaa\_\_hh\_mm\_ss.txt","w"))!= NULL) { //Leer archivo de excel while(!feof(F)) { fgets(VIN,8,F); fgets(hora,19,F); fprintf(G, "%s %s", &VIN, &hora); } } fclose(G); fclose(F);
}
-
Good Morning everybody. I'm developing a program in C++. It is supposed that the program has to read from excel and write the data in a .txt file. It has to do that during 10 minutes, and after that save the .txt and start doing it again. How can I do the timer? May you help me please? The program I write is this one: (Not sure if is correct)
#include
#include
#include
#include
#include
#includeusing namespace std;
struct vehiculo
{
char VIN[8]
char hora[19]
};
int main()
vehiculo cocheentrante
{
File *F;
File *G;//Abrir archivo de Excel F = fopen("C:\\Users\\Ford\\Usuarios\\Cristales\\VINES.csv", "rt"); if (F == NULL) { cout << "No se pudo abrir el archivo de entrada. \\n"; } else { cout << "El archivo se abrio correctamente. \\n"; } //Crear archivo txt G = fopen("dd\_mm\_aaaa\_\_hh\_mm\_ss.txt","w"); if((G = fopen("dd\_mm\_aaaa\_\_hh\_mm\_ss.txt","w"))!= NULL) { //Leer archivo de excel while(!feof(F)) { fgets(VIN,8,F); fgets(hora,19,F); fprintf(G, "%s %s", &VIN, &hora); } } fclose(G); fclose(F);
}
See C++ Timer using std::chrono · GitHub[^]. Alternatively you could just use one of the simple time functions (time, _time32, _time64 | Microsoft Docs[^]) and monitor it as your code runs.
-
Good Morning everybody. I'm developing a program in C++. It is supposed that the program has to read from excel and write the data in a .txt file. It has to do that during 10 minutes, and after that save the .txt and start doing it again. How can I do the timer? May you help me please? The program I write is this one: (Not sure if is correct)
#include
#include
#include
#include
#include
#includeusing namespace std;
struct vehiculo
{
char VIN[8]
char hora[19]
};
int main()
vehiculo cocheentrante
{
File *F;
File *G;//Abrir archivo de Excel F = fopen("C:\\Users\\Ford\\Usuarios\\Cristales\\VINES.csv", "rt"); if (F == NULL) { cout << "No se pudo abrir el archivo de entrada. \\n"; } else { cout << "El archivo se abrio correctamente. \\n"; } //Crear archivo txt G = fopen("dd\_mm\_aaaa\_\_hh\_mm\_ss.txt","w"); if((G = fopen("dd\_mm\_aaaa\_\_hh\_mm\_ss.txt","w"))!= NULL) { //Leer archivo de excel while(!feof(F)) { fgets(VIN,8,F); fgets(hora,19,F); fprintf(G, "%s %s", &VIN, &hora); } } fclose(G); fclose(F);
}
How about create your program to just do the file I/O, and then let windows handle the timer/scheduling part?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles