Jump to content

How to load up files With C++

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
CPlusPlus

CPlusPlus

    Newbie

  • Members
  • PipPip
  • 29 posts
How do i load up a file into the C++ Script??

#2
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts
Here is some code for you:


// Include the fstream library

#include<fstream.h>

    

int main()

    {

        // Create a String

        char fileString[2000];

        

        // Open the file

        fstream fo("c:\\path\filename",ios::in);

        

        // Loop through the reading

        while(fo >> fileString)

           cout << fileString ; // Display contents

        

        // Close the file

        file_op.close();


        return 0;

}


This is for Ansi C++ - what you wanted correct?

#3
CPlusPlus

CPlusPlus

    Newbie

  • Members
  • PipPip
  • 29 posts
Yes, thanks alot!

#4
CPlusPlus

CPlusPlus

    Newbie

  • Members
  • PipPip
  • 29 posts
so how would i use it for like a background in the title screen of a game?