Thread: Programming question

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Thumbs up Programming question

    What code would I have to add to this to enable it to load a previously created file into the program...?



    #include <iostream>
    #include <fstream>

    using namespace std;

    main()
    {
    ofstream output;

    output.open("file.txt");

    output << "1 2 3 4";

    output.close();
    int var1, var2, var3, var4;

    ifstream input;

    input.open("file.txt");

    input >> var1 >> var2 >> var3 >> var4;

    input.close();
    }


    Thanks
    -Chris

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    lol..... look at your code.... first you write a file called file.txt then you read it back in again..... the code is already there.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM