Files

This is a discussion on Files within the Windows Programming forums, part of the Platform Specific Boards category; How can I input a file in my program so that at the beginning his information will be put out ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    24

    Question Files

    How can I input a file in my program so that at the beginning his information will be put out on the screen??

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Code:
    #include <fstream>
    #include <string>
    #include <iostream>
    
    using namespace std;
    
    int main(void)
    {
    	string input;
    	ifstream in("c:\\new.txt");
    
    	while(!in.eof())
    	{
    		getline(in, input, (char)EOF);
    		cout<<input;
    	}
    
    	return 0;
    }
    That's the most basic way I know...it's in C++.

    Be more specific and I can tell you want you want to hear
    Last edited by -KEN-; 01-18-2003 at 03:09 PM.

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    24
    yes but this doesn't work under win32 API

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    It really does, though...that's the beautiful thing about it.

    look, I'll compile it on MSVC++ and stick it into a windows app rrrriiiiigggghhhhtttt.....now! ::clicky:: "Compiling..." - look at that, no errors. ::runs program:: and hey, look at that! It runs!

    Sure, there are specific functions you can use for WinAPI file I/O, but they're not particularly neccesary.

  5. #5
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Of course, that was just an example to show you the file I/O aspect of it. The cout and main() won't compile in a windows program, if that's what you meant.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 06:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM

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