Hilfe bei meinen Projekt

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von Korllino, 10. September 2005 .

Schlagworte:
  1. 10. September 2005
    hoi hoi

    also, ich hab mal was gecodet, das was etz hier steht is ein bsp.

    Code:
    #include <iostream.h>
    #include <fstream.h>
    #include <conio.h>
    
    using namespace std;
    
    int main ()
    {
    char zahl1;
    char zahl2;
    
    cout << "Bitte Zahl eingeben: ";
    cin >> zahl1;
    cout << "" << endl;
    
    ofstream out ("text.txt");
    out << "Zahl:" << endl;
    
    getch ();
    return 0
    
    }
    
    so und ich will jetzt, damit das so aussieht, wenn der text ausgegeben wird


    Code:
    Zahl: 1
    
    also, damit wenn man im dos fenster 1 eingegeben hat, damit das in die txt so wie oben reingeschrieben hat,

    wie geht das?

    ich habs so versucht.

    Code:
    
    #include <iostream.h>
    #include <fstream.h>
    #include <conio.h>
    
    using namespace std;
    
    int main ()
    {
    char zahl1;
    char zahl2;
    
    cout << "Bitte Zahl eingeben: ";
    cin >> zahl1;
    cout << "" << endl;
    
    ofstream out ("text.txt");
    out << "Zahl" << zahl1 << "" << endl;
    
    getch ();
    return 0
    
    }
    
    aber so geht das net weiß jemand wie ich das so machen kan, damit dann die zahl die oben im dos eingeschrieben wird, in die txt gespeichert wid ?(
     
  2. 10. September 2005
    ich code zwar erst 3 wochen c++ iner schule aber ich habs mal so gemacht und der speichert die zahl die man eingibt iner txt

    Code:
    #include <iostream.h>
    #include <fstream.h>
    #include <conio.h>
    
    int main ()
    {
     float zahl1;
    
     cout << "Bitte Zahl eingeben: ";
     cin >> zahl1;
    
     ofstream out ("text.txt");
     out << "\nZahl" << zahl1 << endl;
    
     getch ();
     return 0;
    }
    
     
  3. 11. September 2005
    So wie es LordSash gemacht hat, ist es beinahe korrekt. Was mich noch stört, ist, dass er die alten Header benutzt. Laut Standard fällt die Endung .h nun weg. So langsam sollten das aber alle Tutorials / Bücher / etc übernommen haben. D.h. es sieht nun so, oder ähnlich, aus:
    Code:
    #include <fstream>
    #include <iostream>
    
    int main() {
     std::cout << "Zahl eingeben: ";
    
     int number;
     std::cin >> number;
    
     std::ofstream fout("txt");
     fout << number;
    }
    
    so long
     
  4. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.