Click here to Skip to main content
15,912,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC Pin
Tonio17-Aug-00 20:26
Tonio17-Aug-00 20:26 
GeneralRe: MFC Pin
Frank Deo18-Aug-00 7:02
Frank Deo18-Aug-00 7:02 
Generalintrusion into another app Pin
Alexa Polsky17-Aug-00 9:00
sussAlexa Polsky17-Aug-00 9:00 
GeneralLanguage support for dialogs Pin
Chris Vischer17-Aug-00 4:58
Chris Vischer17-Aug-00 4:58 
GeneralRe: Language support for dialogs Pin
Blake Miller22-Aug-00 9:53
Blake Miller22-Aug-00 9:53 
GeneralAccessing to Http header data in IE COM Pin
Ryan Park16-Aug-00 14:12
Ryan Park16-Aug-00 14:12 
GeneralBasic query regarding arrays/data sets Pin
Charlie the Wonderhorse16-Aug-00 11:02
sussCharlie the Wonderhorse16-Aug-00 11:02 
GeneralRe: Basic query regarding arrays/data sets Pin
Philip Nicoletti17-Aug-00 8:30
Philip Nicoletti17-Aug-00 8:30 
If I understand your question correctly :

1) you have files with a bunch of integers in them
2) you want to read these integers into an array
3) (possibly) manipulate the integers
4) (possibly) write the integers out to file again


One possible solution :

At the top of your CPP file :

#define MAX_RECORDS 1000    // max number of data integers

int array[MAX_RECORDS];     // the array of data integers

int numRecords;             // actual number of integers
                            // in the file


To bring up a file open dialog and read in the data :

CFileDialog ifile(TRUE,"txt",NULL,OFN_HIDEREADONLY,
		"text files|*.txt|all files|*.*||");

int result = ifile.DoModal();

if (result == IDOK)
{
   CString info;		
   info = ifile.GetPathName();

   ifstream infile;
   infile.open(info);

   numRecords = 0;

   while (!infile.eof())
   {
      if (numRecords == MAX_RECORDS) break;
      infile >> array[numRecords];
      numRecords++;
   }
   if (infile.eof()) numRecords--;

   infile.close();

}


to bring up a file save dialog and write the
data integers to file :

CFileDialog ofile(FALSE,"txt",NULL,OFN_OVERWRITEPROMPT,
                 "text files|*.txt|all files|*.*||");

int result = ofile.DoModal();

if (result == IDOK)
{

   CString info;		
   info = ofile.GetPathName();

   ofstream outfile;
   outfile.open(info);

   for (int i=0; i<numRecords; i++)
                   outfile << array[i] << "\n";

   outfile.close();

}

GeneralRe: Basic query regarding arrays/data sets Pin
Philip Nicoletti17-Aug-00 13:46
Philip Nicoletti17-Aug-00 13:46 
QuestionMinimizeBox in a PropertySheet? Pin
Mathias16-Aug-00 7:50
Mathias16-Aug-00 7:50 
AnswerRe: MinimizeBox in a PropertySheet? Pin
Frank Deo16-Aug-00 10:40
Frank Deo16-Aug-00 10:40 
GeneralAnother socket failure - in Create() call Pin
Alex Alexapolsky16-Aug-00 3:29
sussAlex Alexapolsky16-Aug-00 3:29 
GeneralRegarding Dial up Pin
Krithivasan M. S16-Aug-00 3:14
Krithivasan M. S16-Aug-00 3:14 
GeneralRe: Regarding Dial up Pin
Member 120896516-Aug-00 13:01
Member 120896516-Aug-00 13:01 
QuestionReboot the PC programatically ? Pin
Adalsteinn B. Bjarnason16-Aug-00 1:21
Adalsteinn B. Bjarnason16-Aug-00 1:21 
AnswerRe: Reboot the PC programatically ? Pin
Benedict Verheyen17-Aug-00 5:16
sussBenedict Verheyen17-Aug-00 5:16 
Generalchanging the default mfc icon Pin
Pierre Koerber16-Aug-00 0:10
sussPierre Koerber16-Aug-00 0:10 
GeneralRe: changing the default mfc icon Pin
Benedict Verheyen17-Aug-00 5:30
sussBenedict Verheyen17-Aug-00 5:30 
GeneralCAsyncSocket-debug assertion failed Pin
Alex Alexapolsky15-Aug-00 22:13
sussAlex Alexapolsky15-Aug-00 22:13 
GeneralRe: CAsyncSocket-debug assertion failed Pin
Remus Lazar16-Aug-00 2:27
Remus Lazar16-Aug-00 2:27 
GeneralCAsyncSocket-debug assertion failed Pin
Alex Alexapolsky15-Aug-00 22:11
sussAlex Alexapolsky15-Aug-00 22:11 
QuestionHow to register my program into the startup Pin
koteswara15-Aug-00 18:38
koteswara15-Aug-00 18:38 
AnswerRe: How to register my program into the startup Pin
Remus Lazar16-Aug-00 2:56
Remus Lazar16-Aug-00 2:56 
GeneralAddItem-method for MSHFlexGrid 6.0 Pin
Stefan Alpers15-Aug-00 5:10
sussStefan Alpers15-Aug-00 5:10 
GeneralRe: AddItem-method for MSHFlexGrid 6.0 Pin
Remus Lazar16-Aug-00 2:51
Remus Lazar16-Aug-00 2:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.