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.

wenn '13'(ENTER) dann Schleife abbrechen

Empfohlene Antworten

Veröffentlicht

Hallo,

habe folgendes Problem: möchte mein Programm solange laufen lassen bis die Eingabewerte mehr als 100 tsück sind und wenn die Taste Enter(Ascii'13') gedrückt wird...

Weiss bloß nicht wie man das in c++ realisieren soll... bin sonst in JAVA....

kann mir jmd weiterhelfen?

#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <ctype.h>
#include <stdio.h>

int eins, zwei,i;
char e[100];

int main ()
{
cout<<"\t\tAutomatischer Rechner\n";
cout<<"\nGeben sie bitte Ihre Rechenkette ein:\n\t";
i=0;
do
{
cin>>e[i];
i++;
}
while(i<=100||e[i]=='13');
cout<<endl;
for(i=0;i<=100;i++)
{
cout<<e[i];
}


getch();
return 0;
}

[/PHP]

Die Header heißen <iostream>, <iomanip>, <cctype> und <cstdio>, wobei du die letzten drei gar nicht brauchst.

Der cin-Aufruf kommt sowieso erst dann zurück, wenn der Benutzer die Eingabetaste drückt. Wenn das ganze nur den Zweck haben soll, dass der Benutzer nicht mehr als 100 Zeichen eingibt, dann benutz doch einfach einen std::string, dann hast du das Problem mit der Längenbeschränkung nicht mehr:

#include <iostream> 
#include <string>

using namespace std;

int main ()
{
cout<<"\t\tAutomatischer Rechner\n";
cout<<"\nGeben sie bitte Ihre Rechenkette ein:\n\t";

string line;
getline( cin, line );

cout << line;
} [/code]

Dann brauchst du auch das nichtstandardisierte getch nicht mehr ;)

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.