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

Hallo,

Ich habe einen Quelltext in C++ geschrieben, aber es kommen immer Fehler beim compilieren. Hier der Fehlerhafte Quelltext

#include <ionstream>

using namspace std;


int main()


    cout << "Rechner -geben Sie add für Addition, sub für Subtraktion, mul für Multiplikation,  dif für Division oder qua für Quadrierung ein! [Copyright by Max Petter.]";

    cin Eingabe;

  if (add)

    {

    int Eingabe eins;

    int Eingabe zwei;

    int Summand;

    cout << "Addition -gebe Sie 2 Zahlen ein!" ;

    cin >> Eingabe eins;

    cin >> Eingabe zwei;

    Summand = Eingabe eins + Eingabe zwei;

    cout << "Das Ergebnis lautet:" << Summand << endl;

    }

  else

  {  

  (cout << "Error -falsche Eingabe" <<;

  }

  if (sub)

    {

      int Eingabe eins;

      int Eingabe zwei;

      int Differenz;

      cout << "Subtraktion -geben Sie 2 Zahlen ein!";

      cin >> Eingabe eins;

      cin >> Eingabe zwei;

      Differenz = Eingabe eins - Eingabe zwei;

      cout << "Das Ergebnis lautet:" << Differenz << endl;

    }

	else

	{

	  cout << "Error -falsche Eingabe" <<;

	}

  if (mul)

    {

    int Eingabe eins;

    int Eingabe zwei;

    int Produkt;

    cout << "Geben Sie 2 Zahlen ein!";

    cin >> Eingabe eins;

    cin >> Eingabe zwei;

    Differenz = Eingabe eins * Eingabe zwei;

    cout << "Das Ergebnis lautet:" << Produkt << endl;

    }

    else

    {

    cout << "Error -falsche Eingabe!" << endl;

    }

  if (dif)

  {

    int Eingabe eins;

    int Eingabe zwei;

    int Differenz;

    cout << "Geben Sie 2 Zahlen ein!;

    cin >> Eingabe eins;

    cin >> Eingabe zwei;

    Differenz = Eingabe eins / Eingabe zwei;

    cout << "Das Ergebnis lautet:" << Differenz << endl; 

  }

    else

    {

      cout << "Error -falsche Eingabe" << endl;

    }

  if (qua)

  {

    int Eingabe;

    int Quadrat;

    cout << "Quadrierung -Geben sie eine Zahl ein!";

    cin >> Eingabe;

    Quadrat = Eingabe * Eingabe;

    cout << "Die Quadratzahl lautet:" << Quadrat << endl;

  }

  else

  {

    cout << "Error -falsche Eingabe << endl;

Wie ist dieser Quelltext richtig???

Viele Grüße und Danke im Voraus,

suppenkasper

Ich habe einen Quelltext in C++ geschrieben, aber es kommen immer Fehler beim compilieren.

Fehlermeldung bitte Posten.

Die main-Funktion ist nicht korrekt deklariert und zusätzlich gehört der Code einer Funktion innerhalb geschweifter Klammern

es kommt immer:

max@linux-graw:~> g++ ma.cpp

g++: ma.cpp: Datei oder Verzeichnis nicht gefunden

g++: no input files

ich hatte das Programm nicht ausführbar gemacht. Der Compiler zeigt nun folgende Fehlermeldungen:

ma.cpp:1:21: error: ionstream: Datei oder Verzeichnis nicht gefunden

ma.cpp:58:13: warning: missing terminating " character

ma.cpp:58: error: missing terminating " character

ma.cpp:79:13: warning: missing terminating " character

ma.cpp:79: error: missing terminating " character

ma.cpp:2: error: expected nested-name-specifier before ‘namspace’

ma.cpp:2: error: ‘namspace’ has not been declared

ma.cpp:2: error: expected ‘;’ before ‘std’

ma.cpp:2: error: expected constructor, destructor, or type conversion before ‘;’ token

ma.cpp: In function ‘int main()’:

ma.cpp:6: error: ‘cout’ was not declared in this scope

ma.cpp:7: error: ‘cin’ was not declared in this scope

ma.cpp:7: error: expected ‘;’ before ‘Eingabe’

ma.cpp:8: error: ‘add’ was not declared in this scope

ma.cpp:10: error: expected initializer before ‘eins’

ma.cpp:11: error: expected initializer before ‘zwei’

ma.cpp:14: error: ‘Eingabe’ was not declared in this scope

ma.cpp:14: error: expected ‘;’ before ‘eins’

ma.cpp:15: error: expected ‘;’ before ‘zwei’

ma.cpp:16: error: expected ‘;’ before ‘eins’

ma.cpp:17: error: ‘endl’ was not declared in this scope

ma.cpp:21: error: expected primary-expression before ‘;’ token

ma.cpp:21: error: expected ‘)’ before ‘;’ token

ma.cpp:23: error: ‘sub’ was not declared in this scope

ma.cpp:25: error: expected initializer before ‘eins’

ma.cpp:26: error: expected initializer before ‘zwei’

ma.cpp:29: error: ‘Eingabe’ was not declared in this scope

ma.cpp:29: error: expected ‘;’ before ‘eins’

ma.cpp:30: error: expected ‘;’ before ‘zwei’

ma.cpp:31: error: expected ‘;’ before ‘eins’

ma.cpp:32: error: ‘endl’ was not declared in this scope

ma.cpp:36: error: expected primary-expression before ‘;’ token

ma.cpp:38: error: ‘mul’ was not declared in this scope

ma.cpp:40: error: expected initializer before ‘eins’

ma.cpp:41: error: expected initializer before ‘zwei’

ma.cpp:44: error: ‘Eingabe’ was not declared in this scope

ma.cpp:44: error: expected ‘;’ before ‘eins’

ma.cpp:45: error: expected ‘;’ before ‘zwei’

ma.cpp:46: error: ‘Differenz’ was not declared in this scope

ma.cpp:46: error: expected ‘;’ before ‘eins’

ma.cpp:47: error: ‘endl’ was not declared in this scope

ma.cpp:51: error: ‘endl’ was not declared in this scope

ma.cpp:53: error: ‘dif’ was not declared in this scope

ma.cpp:55: error: expected initializer before ‘eins’

ma.cpp:56: error: expected initializer before ‘zwei’

ma.cpp:59: error: ‘Eingabe’ was not declared in this scope

ma.cpp:59: error: expected ‘;’ before ‘eins’

ma.cpp:60: error: expected ‘;’ before ‘zwei’

ma.cpp:61: error: expected ‘;’ before ‘eins’

ma.cpp:62: error: ‘endl’ was not declared in this scope

ma.cpp:66: error: ‘endl’ was not declared in this scope

ma.cpp:68: error: ‘qua’ was not declared in this scope

ma.cpp:75: error: ‘endl’ was not declared in this scope

ma.cpp:80: error: expected primary-expression before ‘}’ token

ma.cpp:80: error: expected ‘;’ before ‘}’ token

ma.cpp:80: error: expected ‘}’ at end of input

Also was hab ich da falsch gemacht?

ich hatte das Programm nicht ausführbar gemacht.

Bei den Fehlern lässt sich überhaupt kein Executable erstellen. Quellcode Dateien sollte sicherlich nicht das Executable-Flag bekommen.

Also was hab ich da falsch gemacht?

Die Fehlermeldungen sagen Dir, was nicht korrekt ist. Grob gesagt sind Deine Variablen nicht richtig deklariert und initialisiert, sowie andere diverse syntaktische Fehler innerhalb des Codes.

Gast
Dieses Thema ist für weitere Antworten geschlossen.

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.