Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Create a timer

Create a timer

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14865432
    wrote on last edited by
    #1

    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
    #include

    using 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);
    

    }

    L D 3 Replies Last reply
    0
    • M Member_14865432

      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
      #include

      using 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);
      

      }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Member 14865432 wrote:

      I'm developing a programme in C++, and one of the parts of the program

      Let's start with deciding if you want to use British English or American English. ;)

      1 Reply Last reply
      0
      • M Member_14865432

        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
        #include

        using 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);
        

        }

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • M Member_14865432

          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
          #include

          using 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);
          

          }

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups