Hallo,
ich bin hier relativ neu und habe das Buch C++ für Spieleprogrammierer.
So nun habe ich mein erstes Problem.
Ich will ein Programm erstellen, welches als Login dienen soll.
Es gibt drei Benutzernamen (user1,user2,user3) und 3 dazugehörige passwörter (test1,test2,test3).
Man wird aufgefordert sich anzumelden.
Hier mal der Code:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// first programm
//
#include <iostream>
using namespace std;
// main programm
//
int main()
{
// variables
const char login1;
const char login2;
const char login3;
const char pw1;
const char pw2;
const char pw3;
char eingeb1;
char eingeb2;
// variablen definieren
login1 = user1;
login2 = user2;
login3 = user3;
pw1 = test1;
pw2 = test2;
pw3 = test3;
// login
cout << "Melden Sie sich bitte an";
cout << "Login: ";
cin >> eingeb1; // Eingabe des Login
// PW eingeben
cout << "Passwort: ";
cin << eingeb2; // Eingabe des Passworts
// Login / Passwort überprüfen für login1 und pass1
if (eingeb1 == login1 && eingeb2 == pw1)
cout << "Sie sind im Serversystem.";
else
cout << "Probieren Sie es bitte noch einmal, indem Sie das Programm neustarten.";
// Login / Passwort überprüfen für login2 und pass2
if (eingeb1 == login2 && eingeb2 == pw2)
cout << "Sie sind im Serversystem.";
else
cout << "Probieren Sie es bitte noch einmal, indem Sie das Programm neustarten.";
// Login / Passwort überprüfen für login3 und pass3
if (eingeb1 == login3 && eingeb2 == pw3)
cout << "Sie sind im Serversystem.";
else
cout << "Probieren Sie es bitte noch einmal, indem Sie das Programm neustarten.";
return 0;
}
|
Hier mal die Fehlermeldung von Visual C++:
1>------ Neues Erstellen gestartet: Projekt: projekt2, Konfiguration: Debug Win32 ------
1>Die Zwischen- und Ausgabedateien für das Projekt "projekt2" mit der Konfiguration "Debug|Win32" werden gelöscht.
1>Kompilieren...
1>programm1.cpp
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(14) : error C2734: 'login1': Konstantes Objekt muss initialisiert werden, wenn es nicht extern ist
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(15) : error C2734: 'login2': Konstantes Objekt muss initialisiert werden, wenn es nicht extern ist
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(16) : error C2734: 'login3': Konstantes Objekt muss initialisiert werden, wenn es nicht extern ist
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(17) : error C2734: 'pw1': Konstantes Objekt muss initialisiert werden, wenn es nicht extern ist
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(1
: error C2734: 'pw2': Konstantes Objekt muss initialisiert werden, wenn es nicht extern ist
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(19) : error C2734: 'pw3': Konstantes Objekt muss initialisiert werden, wenn es nicht extern ist
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(24) : error C2065: 'user1': nichtdeklarierter Bezeichner
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(25) : error C2065: 'user2': nichtdeklarierter Bezeichner
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(26) : error C2065: 'user3': nichtdeklarierter Bezeichner
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(27) : error C2065: 'test1': nichtdeklarierter Bezeichner
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(2
: error C2065: 'test2': nichtdeklarierter Bezeichner
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(29) : error C2065: 'test3': nichtdeklarierter Bezeichner
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(930): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(930): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(930): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(930): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(923): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(923): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(923): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(923): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(916): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(916): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(916): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(916): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(909): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(909): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(909): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(909): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(871): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(871): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(871): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(871): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(825): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(825): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(825): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(825): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(785): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(785): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(785): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(785): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(73
: Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(73
: Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(73
: Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)": template-Argument für "std::basic_ostream<char,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(73
: Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(700): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(700): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(700): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(700): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(653): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(653): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(653): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2784: "std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)": template-Argument für "std::basic_ostream<_Elem,_Traits> &" konnte nicht von "std::istream" hergeleitet werden.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(653): Siehe Deklaration von 'std::operator <<'
1>c:\users\lars\desktop\c++\projekt2\projekt2\programm1.cpp(3
: error C2676: Binärer Operator '<<': 'std::istream' definiert diesen Operator oder eine Konvertierung in einen für den vordefinierten Operator geeigneten Typ nicht
1>Das Buildprotokoll wurde unter "file://c:\Users\Lars\Desktop\C++\projekt2\projekt2\Debug\BuildLog.htm" gespeichert.
1>projekt2 - 53 Fehler, 0 Warnung(en)
========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ==========
Okay dann hab ich noch eine Frage:
Wie stell ich links bei Vc++ die Zeilenzahl ein?
Wäre nett wenn ihr helfen könntet