Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » Countdown Timer

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: [ 1 ] > 2 <
010
11.11.2004, 08:57 Uhr
Jan-Willem



Gibt es nicht einen allgemeinen Code, denn wir wissen überhaupt nicht wie wir damit anfangen sollen met dem SetTimer (declarations, includes, ...)

Gruss,

Jan-Willem
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
011
11.11.2004, 13:50 Uhr
derphilipder



Zeig Doch einfach mal her, was Ihr bis jetzt versucht habt.
--
Konfuzius says: "A man who goes to bed with an itchy asshole is a man who wakes up with stinky finger!"
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
012
12.11.2004, 10:51 Uhr
~JW
Gast


Hi,

Wir haben dieses code (leider ohne SetTimer() )


C++:
#include <windows.h>
#include <iostream.h>
#include <conio.h>

char *getInput();

void main()
{
    getInput();
    cout<<"U heeft volgende zet gedaan: "<<endl;
}

char *getInput()
{
   char *string = new char[100];
   unsigned long int start = GetTickCount();
   int x = 0;
   while ((GetTickCount() - start) / 1000.0 < 15 && (x == 0 || string[x-1] != 13))
   {
      if (kbhit()) //int kbhit() => which returns true if any character has been typed on the keyboard since it was read last. Since your simulator will need to continually calculate the position of the lift, it must not block (ie suspend execution waiting for some event) waiting for a key to be pressed.
      {
         string[x] = getch();
         cout << string[x];
         cout.flush();
         x++;
      }
   }

   string[x] = '\0';
   cout << endl;


   return string;
}



Habt ihr ein biespiel mit SetTimer() ?

PS. Entschuldige fuhr mein schlechtes Deutsch...
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
013
12.11.2004, 12:58 Uhr
derphilipder



Darfs auch C++ sein?

Also, ich hab das jetzt so verstanden, daß getInput() den eingegebenen string und die Eingabezeit zurückgibt:


C++:
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;

string getInput(float&);

int main()
{    
    float zeit;
    string strg = getInput(zeit);
    cout<<"U heeft volgende zet gedaan: " << zeit << " sekunden\n";

    return 0;
}

string getInput(float& time)
{
   string str;
   unsigned long int start = GetTickCount();
   int x = 0;
   char c;
   while ((time = (float)(GetTickCount() - start) / 1000.0 )< 15 && (x == 0 || str[x-1] != 13))
   {
      if (kbhit()) //int kbhit()
      {
         c = getch();
         str += c;
         cout << c ;
         x++;
      }
   }

   cout << endl;
   return str;
}



--
Konfuzius says: "A man who goes to bed with an itchy asshole is a man who wakes up with stinky finger!"
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
014
12.11.2004, 18:38 Uhr
~JW
Gast


Das darft sicher c++ sein, besser noch

Aber unsere program musst in QT(Graphical)

Hast du auch ein beispiel von SetTimer() ?

Danke und gruss
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: [ 1 ] > 2 <     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: