• Lucid Dreaming - Dream Views




    Results 1 to 25 of 102
    Like Tree3Likes

    Thread: Ask me about C / C++

    Threaded View

    1. #7
      Banned
      Join Date
      May 2007
      LD Count
      Loads
      Gender
      Location
      Digital Forest.
      Posts
      6,864
      Likes
      386
      Quote Originally Posted by The Invisible Man View Post
      Crap, I meant C++. Sorry, but... um.... yeeeeeeeeeeeeaaaaaaaaaaah. Could I get that the Open File command on C++? Command for the Standard Library?
      Code:
      #include <iostream>
      #include <fstream>
      #include <string>
      
      using namespace std;
      
      int main(){
          fstream FILE("foo.txt",ios_base::trunc); //First, we open a file named "foo.txt", overwriting any existing data. (signified by ios_base::trunc for truncate ;))
          
          if(!FILE.is_open();){ //If the file opens, then continue
              FILE<<"Stuff to write\n"; //Write to the File stream using the insertion operators <<
              string In;
              FILE>>In; //Read from the stream using the extraction operators >>
          }
          return EXIT_SUCCESS; //Because macros are just way cooler than constants
      }
      Last edited by A Roxxor; 05-23-2009 at 01:46 AM.

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •