Thread: Need help migrating console app to windows app

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    1

    Need help migrating console app to windows app

    I am having trouble trying to figure out how to get a console app into a windows version of C++. My code basically takes a txt file and manipulates it to remove a form feed char and add 20 blank lines. I can do this easy in a console app like this:

    Code:
    #include "stdafx.h"
    #include "iostream.h"
    #include "fstream.h"
    
    ifstream infile;
    ofstream outfile;
    
    int main(int argc, char* argv[])
    {
      char next;
    
      infile.open("C:/test.txt");
      outfile.open("C:/outfile.txt");
    
      infile.get(next);
    
          while (! infile.eof())
          {
                    if (next == (char)12)		
    	{
    		int cnt;
    		for (cnt = 1; cnt <= 20; cnt++)
    		    outfile << "\n";			
    	      
    	}
    	else			
    		outfile.put(next);	
    		
    	infile.get(next);					
          }
    
    	infile.close();
    	outfile.close();
    return 0;
    }
    How would i get this into, say, a simple windows program, like a single document MFC wizard program to process this code when i open the file? I read alittle on serialization but dont have any examples to work with.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    MFC's serialization uses binary files, and the file opening code is usually for documents that stay open. Anways, the way I would do it is just overide the default function for opening a file from the message map. Then create a CFileDialog object, call DoModal, retrieve the file, and call the function that removes line feeds.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  2. Shift-JIS enabled Console on Windows 2000
    By Lynux-Penguin in forum Tech Board
    Replies: 0
    Last Post: 08-21-2003, 05:36 PM
  3. windows dos console
    By dune911 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-16-2002, 11:30 PM
  4. console to windows
    By itld in forum Windows Programming
    Replies: 2
    Last Post: 01-12-2002, 01:48 AM
  5. Turning a Console APP into Windows.
    By Darkflame in forum C++ Programming
    Replies: 3
    Last Post: 09-14-2001, 03:10 AM