|
separate each field with a comma :
1, Tan Chin Chee, 1234456666, Exp 1, Exp 2, Exp 3, A
or put " around strings
1 "Tan Chin Chee" 1234456666 "Exp 1" "Exp 2" "Exp 3" "A"
or store your file as an xml file.
|
|
|
|
|
i have already tried various type of storing ways. I have tried to store the names as char,string,int,double,float...everything i can think of. But it just won't read the name. Weird~~
|
|
|
|
|
tanchinchee wrote: i am trying to develop a table...
In a database?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
To read the name list from a database..Yes
|
|
|
|
|
tanchinchee wrote: To read the name list from a database..Yes
Then why are you wanting to "...develop a table?" Developing a table, and reading from it, are two different things.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
o i might be misleading you. Act i am trying to read the name from a database and then cout it into a table.
|
|
|
|
|
tanchinchee wrote: Act i am trying to read the name from a database and then cout it into a table.
So does section17.txt represent the "database" that you are reading from? If so, what does it look like?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Message Closed
modified 27-Jan-22 7:04am.
|
|
|
|
|
Ok, how many columns is each row comprised of?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well in my table there are suppose to be 5 columns. Which will look like this
Num Name I/C Group Week
Week 1 Week 2 Week 3
|
|
|
|
|
tanchinchee wrote: Well in my table there are suppose to be 5 columns.
So why the two rows?
In any case, as Maximilien has already suggested, you need a way of delimiting each column with something other than a space. Sans that, it's not possible to differentiate between a space between columns and a space within a column.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Opps sorry...plz omit the second row...
|
|
|
|
|
Hi, i have a weird problem i can't seem to find the source of the problem.
I have an edit box with a button to allow browsing for file. When i debug, i found out that under outputdata>_Fb>_Str, _Str value is 0x00000000 {???}. This causes the file unable to open. Is the problem lies in any of the functions? Can anyone help me to explain what may cause this problem? Below are the codes and any replies or advice is highly appreciated:
void MyDlg::OnBrowse()
{
OPENFILENAME openfile;
openfile.lStructSize=sizeof(OPENFILENAME) ;
openfile.hwndOwner=AfxGetApp()->m_pMainWnd->m_hWnd;
openfile.lpstrFilter="Text Files (.txt)\0*.txt\0All Files (*.*)\0*.*\0";
UpdateData();
openfile.lpstrInitialDir=m_binfile;
openfile.lpstrTitle="Specify file";
openfile.lpstrCustomFilter=NULL;
CString ext=m_binfile.Right(3);
ext.MakeUpper();
openfile.nFilterIndex=1;
CString binfile=m_binfile;
binfile=binfile.Mid(binfile.ReverseFind('\\')+1);
char file[MAX_PATH];
file[0]=0;
strcpy(file,binfile);
openfile.lpstrFile=file;
openfile.nMaxFile=MAX_PATH;
openfile.lpstrFileTitle=NULL;
openfile.Flags=OFN_HIDEREADONLY;
openfile.nFileOffset=0;
openfile.nFileExtension=0;
openfile.lpstrDefExt=ext;
openfile.lCustData=0;
if (GetOpenFileName(&openfile))
{
m_binfile=file;
UpdateData(FALSE);
OnLoad();
}
}
void CICTesterDlg::OnLoad()
{
UpdateData();
CString file;
file="abc.txt";
std::ifstream outputdata;
outputdata.open(file), ios::in);
if ( !outputdata.is_open() )
{
MessageBox(_T("Unable to open file!"),_T("WARNING"),MB_ICONEXCLAMATION);
return;
}
outputdata.close();
}
|
|
|
|
|
cyn8 wrote: When i debug, i found out that under outputdata>_Fb>_Str, _Str value is 0x00000000 {???}. This causes the file unable to open.
I don't see any code like this. What am I missing?
This is the file open code I see:
CString file;
file="abc.txt";
std::ifstream outputdata;
outputdata.open(file), ios::in);
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
_Str can be seen in the debug window. It is under the outputdata variable. Besides that, is OnBrowse function lacking of any command. The file can't open whenever the OnBrowse function is used.
|
|
|
|
|
After a successful GetOpenFileName call, what is in your "file" (openfile.lpstrFile) array?
You copy it to another variable like this:
m_binfile=file;
but your code sample trie to open a different file.
???
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
actually i modify the code pasted here as the original code is too long. The file i open in OnBrowse is different from the one in Onload. However, i think the OnBrowse function somehow affect the opening of the file in OnLoad. This is because, if i didn't clicked on OnBrowse before i clicked on Onload, the file can be open without error. But i don't understand why this is happening...please help...it's urgent..Thank you
|
|
|
|
|
cyn8 wrote: ...please help...it's urgent..
If the file open is failing then the pathname you are passing is invalid.
That's something you'll have to check in the debugger.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I've check the path name and it is correct.Is the method use in OnBrowse affect anything in opening other files? Because when OnBrowse button has been click and the 'Open' button is clicked, other method(by selecting the file specified in a combobox) which has no problem before the browse button is clicked, is unable to open the file.
|
|
|
|
|
Other than changing the current directory, I don't know how the openfilename dialog can effect
opening a file.
Are you supplying a full pathname or just a filename to open?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Just the file name to open. I put the file at same folder as the .exe file. So it should be able to open.
|
|
|
|
|
But what argument is being passed to the ifstream constructor? Don't assume...know.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
cyn8 wrote: I put the file at same folder as the .exe file. So it should be able to open.
Not true. Just to make sure, I just tried it.
That works when loading DLLs with LoadLibrary but not files. You'll need to get the exe's folder
and append it if you want to do that (or set the current working directory to it). See
the "GetModuleFileName" API.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
the file that i want to open is a *txt file. The .exe file that i meant is the file to start the dialog application. Sorry for the misunderstanding.
|
|
|
|
|
Right - I'm following
You still need a valid path though (either explicit or set with SetCurrentDirectory)!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|