Home > Software engineering >  How to open a TXT data and enter into my calculation
How to open a TXT data and enter into my calculation

Time:10-03

In an algorithm, I make a life for in2txr file is copied to the project, there are 2 * 1024 number,
And then into my algorithm leads to number three,

Now teacher told me to MFC to do a dialog box, using MFC open a TXT, contains 1024 number 2 * instead I copied the in2 reading method, under the project
A bit like this

MFC small white please the great god give directions, interrupt system recommended by the great god,

CodePudding user response:

GetOpenFileName function

CodePudding user response:

With CFileDialog and select the file, and then the file path, read it again

CodePudding user response:

Moderators of I

CodePudding user response:

refer to the second floor oyljerry response:
with CFileDialog etc. Select the file, the file path, then read

Disturb the moderator thank you very much

CodePudding user response:

CodePudding user response:


reference 1st floor zgl7903 response:
GetOpenFileName function


How and when opened my source code freopen correlation

CodePudding user response:

refer to the second floor oyljerry response:
with CFileDialog etc. Select the file, the file path, then read


Webmaster hello how can I open and associated ah let me source freopen freopen TXT read entered is open

CodePudding user response:

refer to 7th floor zhenfuyou9588 response:
Quote: refer to the second floor oyljerry response:

Use CFileDialog select files, such as access to the file path, then read


Webmaster hello how can I open and I source freopen associated ah let freopen open is read in TXT

Cstrings path;
CFileDialog DLG.
DLG. DoModal ();
Path=DLG. GetPathName ();
Freopen (path, "r", stdin);

CodePudding user response:

refer to the eighth floor a393062456 response:
Quote: refer to 7th floor zhenfuyou9588 response:

Quote: refer to the second floor oyljerry response:

Use CFileDialog select files, such as access to the file path, then read


Webmaster hello how can I open and I source freopen associated ah let freopen open is read in TXT

Cstrings path;
CFileDialog DLG.
DLG. DoModal ();
Path=DLG. GetPathName ();
Freopen (path, "r", stdin);


Hello, as you say I wrote, tip error is path is cstrings, can't get the FILE from cstrings, stdin this parameter and also the FILE argument is not compatible

CodePudding user response:

references 9 f zhenfuyou9588 response:
Quote: refer to the eighth floor a393062456 response:

Quote: refer to 7th floor zhenfuyou9588 response:

Quote: refer to the second floor oyljerry response:

Use CFileDialog select files, such as access to the file path, then read


Webmaster hello how can I open and I source freopen associated ah let freopen open is read in TXT

Cstrings path;
CFileDialog DLG.
DLG. DoModal ();
Path=DLG. GetPathName ();
Freopen (path, "r", stdin);


Hello, as you say I wrote, tip error is path is cstrings, can't get the FILE from cstrings, stdin this parameter and the FILE of the argument is not compatible with


==================
No error after I change freopen_s freopen stdin, path, or an error

CodePudding user response:

CodePudding user response:

LPSTR (LPCSTR) path

CodePudding user response:

references to the tenth floor zhenfuyou9588 response:
Quote: references 9 f zhenfuyou9588 response:

Quote: refer to the eighth floor a393062456 response:

Quote: refer to 7th floor zhenfuyou9588 response:

Quote: refer to the second floor oyljerry response:

Use CFileDialog select files, such as access to the file path, then read


Webmaster hello how can I open and I source freopen associated ah let freopen open is read in TXT

Cstrings path;
CFileDialog DLG.
DLG. DoModal ();
Path=DLG. GetPathName ();
Freopen (path, "r", stdin);


Hello, as you say I wrote, tip error is path is cstrings, can't get the FILE from cstrings, stdin this parameter and the FILE of the argument is not compatible with


==================
No error after I change freopen_s freopen stdin, path, or an error

This is because the parameters of the freopen is char * type, do you want to convert cstrings type to string,
String temp=path. GetBuffer ();
Path. RealseBuffer ();
Freopen (temp. C_str (), "r", stdin);
  • Related