New @ Visual C++ 2005

This is a discussion on New @ Visual C++ 2005 within the C++ Programming forums, part of the General Programming Boards category; Could anyone tell me the syntax to input a file? My program has accesss to the location of the file ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    3

    New @ Visual C++ 2005

    Could anyone tell me the syntax to input a file?
    My program has accesss to the location of the file through a open file dialog...
    I tried everything..even the tutorial on MSDN, but it won't work .

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Don't exactly understand question, but you will probably want fstream.

    http://www.cprogramming.com/tutorial/lesson10.html

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    3
    I'm sory if I wasn't clear, I want to know the syntax to open a file in Visual C++ 2005. I tried the fstream...didn't realy work..maybe I did something wrong?
    I added the header files at the top of my source and added the code. I read somewhere that I would have to change CLR to the old syntax, but then everything else stops working.

  4. #4
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    I'm almost sure fstream should work. Here's sample code that should be vary easy to integrate

    Code:
    #include <fstream>
    #include <string>
    using std::ifstream;
    using std::string;
    string Read_File(char * name)
    {
    	ifstream in;
    	string file;
    	in.open(name);
    	char temp;
    	while (temp = in.get())
    		file += temp;
    	return file;
    }
    If that doesnt work then use this as a last resort
    http://msdn.microsoft.com/library/de...s/readfile.asp

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    3
    TY very much!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 09:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21