Thread: opening files

  1. #1
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269

    opening files

    How do you make the program open up a file and then save a file?

    thx.
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  2. #2
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    scratch the above;

    what is the prototype for:

    loadDOC (filename);

    ????
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  3. #3
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    hey

    bluehead, whatever happened to xterria? arent you two friends or something?

  4. #4
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    I haven't seen him in a while, have you?
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    21
    Not sure if this is what your after, but in its most basic form, i'd do it like this:

    #include <fstream.h>

    main()
    {
    char ch;
    char filename[20] = "c:test.txt";
    int mode = ios:ut;
    fstream fout(filename, mode );
    cout << "Ready for input, use CTRL+Z to end" << endl;
    while ( cin.get( ch ) )
    {
    fout.put( ch );
    }
    fout.close();
    return(0);
    }

    fout.close(); is important, miss it and you could **** up your whole hd.

    to open the file:

    #include <fstream.h>

    main()
    {
    char ch;
    char filename[20] = "c:test.txt";
    int mode = ios::in;

    fstream fin(filename, mode );
    if (!fin)
    cout << "Unable to open file";
    while ( fin.get(ch) )
    {
    cout << ch;
    }
    fin.close();
    return(0);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opening ASCII files in C?
    By Mavix in forum C Programming
    Replies: 6
    Last Post: 04-25-2007, 02:23 PM
  2. Need help opening a series of files
    By ramparts in forum C Programming
    Replies: 9
    Last Post: 11-14-2006, 05:49 PM
  3. Opening files with UNICODE file names
    By decohk in forum Linux Programming
    Replies: 2
    Last Post: 11-09-2006, 05:25 AM
  4. opening files
    By angelic79 in forum C Programming
    Replies: 3
    Last Post: 10-19-2004, 06:52 AM
  5. Opening files - Giving options?
    By wwwGazUKcom in forum C++ Programming
    Replies: 3
    Last Post: 09-18-2001, 07:06 AM