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.

VC++ und getch()

Empfohlene Antworten

Veröffentlicht

Hallo

Mal ne kleine Erfahrungsfrage.

ein Freund hat wie gefragt wieso VC++ dies nicht kann.

.

.

{

cout << "Hallo";

getch();

};

mehr ist nicht im Programm, wieso wird erst getch() ausgeführt und Hallo taucht nur für ganz kurz auf.

Hab das spasseshalber mal eingetippt (Borland, BloodShed) reagieren, wie ich es erwarte. VC++ nicht.

Das gleiche mit system("pause") und kbhit();

printf() anstatt cout funktioniert allerdings.

Mit funktioniert nicht, meinte ich nicht das compilen oder linken, sondern die Funktionalität.

Es ist nur so, dass das Konsolenfenster aufgeht, es auf eine taste wartet und Hallo schreibt und das fenster schließt.

Hilft es evtl. wenn du vor getch() fflush(stdin) aufruft?

Probier es mal mit einem <<endl; nach dem "Hallo".

Dadurch wird nämlich Hallo ausgegeben und erst dann auf ne Tastatur Eingabe gewartet

Original geschrieben von Smoggy

Probier es mal mit einem <<endl; nach dem "Hallo".

Dadurch wird nämlich Hallo ausgegeben und erst dann auf ne Tastatur Eingabe gewartet

Das ';' am ende der Zeile 'cout << "Hallo";' bewirkt das gleiche wie endl! Aber wir hatten das Problem auch und haben es nicht gelöst bekommen. Wäre gut wenn da jemand was zu wüßte.

Bine

Das ; bewirkt nich das selbe wie endl; :

bei endl springt der cursor in eine neue Zeile....

Cout/Cin "spinnen" bei solchen Konsolenbefehlen etwas.

Habt ihr es denn schon mal mit endl probiert???? anscheinend nicht, sonst würds ja funzen....

Doch, ich weiß wir haben es probiert und es hat trotzdem nicht geklappt.

Bine

Hmm, hab's gerade hier noch mal ausprobiert, und bei der simplen Funtkion funktioniert es.

Weiß auch nicht warum damals nicht.

Bine

Siehste, wenn Papa sacht: Datt klappt, dann klappt datt auch....und wenn et zusammen klappt, hauptsache et klapp :) :)

Danke Leute, ist mir zwar nicht logisch, aber egal.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.