Fabian Braennstroem
19 years ago
Hi,
I am pretty new to C++ and wx programing and try to open a
data file using wxFileDialog and fopen.
I am able to choose a file using the lines from an example,
but how can I adjust the filename of fopen for using fscanf
later on?
wxFileDialog dialog
(
this,
_T("Testing open file dialog"),
wxEmptyString,
wxEmptyString,
#ifdef __WXMOTIF__
_T("C++ files (*.log)|*.log")
#else
_T("C++ files (*.log;*.h)|*.log;*.h")
#endif
);
dialog.SetDirectory(wxGetHomeDir());
// Message Nach dem Öffnen
if (dialog.ShowModal() == wxID_OK)
{
wxString info;
info.Printf(_T("Full file name: %s\n")
_T("Path: %s\n")
_T("Name: %s"),
dialog.GetPath().c_str(),
dialog.GetDirectory().c_str(),
dialog.GetFilename().c_str());
wxMessageDialog dialog2(this, info, _T("Selected file"));
dialog2.ShowModal();
}
fz=fopen(dialog.GetFilename().c_str(),"r");
cout << "output: " << dialog.GetFilename().c_str() << endl;
Even the last cout statement just prints the memory address, but
not the file name.
Do you have an idea?
Greetings!
Fabian
I am pretty new to C++ and wx programing and try to open a
data file using wxFileDialog and fopen.
I am able to choose a file using the lines from an example,
but how can I adjust the filename of fopen for using fscanf
later on?
wxFileDialog dialog
(
this,
_T("Testing open file dialog"),
wxEmptyString,
wxEmptyString,
#ifdef __WXMOTIF__
_T("C++ files (*.log)|*.log")
#else
_T("C++ files (*.log;*.h)|*.log;*.h")
#endif
);
dialog.SetDirectory(wxGetHomeDir());
// Message Nach dem Öffnen
if (dialog.ShowModal() == wxID_OK)
{
wxString info;
info.Printf(_T("Full file name: %s\n")
_T("Path: %s\n")
_T("Name: %s"),
dialog.GetPath().c_str(),
dialog.GetDirectory().c_str(),
dialog.GetFilename().c_str());
wxMessageDialog dialog2(this, info, _T("Selected file"));
dialog2.ShowModal();
}
fz=fopen(dialog.GetFilename().c_str(),"r");
cout << "output: " << dialog.GetFilename().c_str() << endl;
Even the last cout statement just prints the memory address, but
not the file name.
Do you have an idea?
Greetings!
Fabian