Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Ich möchte eine Fehlermeldung für 8 Sekunden anzeigen. Wie mach ich das in C++?

z.B.:

cout << "Diese Eingabe ist nicht zugelassen!";

// 8 sek warten

system("cls");

Gruß

Ich hatte sleep() genommen und den Bezeichner gibt es nicht.

So sind Anfänger!

Danke!

Also so weit ich weiß, klappt sleep (...) sowohl bei Windows als auch bei Linux. Nur dass bei Windows die Zahl in den Klammern Millisekunden bedeutet und bei Linux Sekunden. Glaube ich zumindest.

LG

Daiana

Hallo,

für die Unix-Derivate und Linux existieren sleep() bzw. usleep(). sleep(n) wartet n Sekunden, usleep(n) n Mikrosekunden (das "u" wurde an Anlehnung an den griechischen Buchstaben "mü" gewählt).

Nic

Ja Danke!

Der Unterschied lag nur bei Sleep() statt sleep(). :rolleyes:

Hab mal irgendwo gelesen, das man das auch so machen kann.

#include <time.h>

#include <sys/timeb.h>

void warte(int ms)

{

struct timeb t;

long zeit = 0;

tzset();

ftime(&t);

long start = (t.time - 900000000)*1000 + t.millitm;

while(zeit < ms)

{

tzset();

ftime(&t);

long stop = (t.time - 900000000)*1000 + t.millitm;

zeit = stop - start;

}

}

@ stico

Keine gute Idee, denn der Prozessor ist voll beschäftigt während er wartet.

Hallo,

aus dem Grund sollte man an dieser Stelle auch mit select() als Workaround arbeiten (Code-Schnipsel anbei):


void mySleep(int sec) {

  struct timeval timeout;


  timeout.tv_sec = sec;

  timeout.tv_usec = 0;

  select(0,0,0,0, &timeout);

}

Nic

Ich hab ja gesagt ich habs irgendwo gelesen, das wusste ich nicht.

Aber goßes DANKE , für den Hinweiß.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.