Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    264
    Thanks
    19
    Thanked 0 Times in 0 Posts

    C/++ Programming

    I'm looking to load a text file to input into my options. It will load from the installation directory of C:\install\. I want to load the text file into a variable like so:

    option = file.txt;

    Not exactly sure how to do this. I researched information on this and have found some ways using open() however I am not sure if this would do what I am needing.

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Well there are different ways of doing it depending on if you are using C or C++. Which one are you using?
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Posts
    264
    Thanks
    19
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oracleguy View Post
    Well there are different ways of doing it depending on if you are using C or C++. Which one are you using?
    It has a combination of both, so C/C++ will work.

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    The easiest method is using the ifstream class in C++: http://www.cplusplus.com/reference/i.../ifstream.html
    OracleGuy

  • #5
    Regular Coder
    Join Date
    Sep 2007
    Posts
    264
    Thanks
    19
    Thanked 0 Times in 0 Posts
    is it possible to use it in a variable?

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by IFeelYourPain View Post
    is it possible to use it in a variable?
    What do you mean?
    OracleGuy

  • #7
    Regular Coder
    Join Date
    Sep 2007
    Posts
    264
    Thanks
    19
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oracleguy View Post
    What do you mean?
    texture = file.txt

    So I can load a texture from a text file.

  • #8
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    The filename you provide the ifstream class can be from a variable, yes.
    OracleGuy


  •  

    Posting Permissions

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