|
Hello,
is there any function for strip a string, file lines?
This is a text file with tab as separator.
Lets say we have a file with this format:
index fname lname age ...
1 name lname 20
Now strip index fname lname etc. in own values...
Thanx for any sugestion
termal
|
|
|
|
|
termal wrote:
Now strip index fname lname etc. in own values...
Normally, "strip" means remove. It sounds like you want to parse tab-delimited lines into separate variables. Yes?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
as i understood, it seems that he wants to strip the first line (which contains the columns headers)
but he'll probably need to parse over the tab too
|
|
|
|
|
Hello,
yes, sorry about my question!
You have right, i like to parse a tab-delimited lines into separate variables,
ok, i have all to show in grid so i look for a function, or idea to do this!
(and yes, i skip the first line with headers this part works )
When i try to parse the line, at end of file i have symbols like this: "ÌÌÌÌÌÌÌÌÌÌ", why that?
thanks
termal
-- modified at 10:33 Monday 7th May, 2007
|
|
|
|
|
Can you post your code that does the parsing?
|
|
|
|
|
Hi,
my first error, this with symbols, i read wrong maybe.
Ok, here is the first try:
char acbuff[4097];
while(0 != (iReadSize = stdFile.Read(contentbuffer, 4096)))
{
csFileContent += contentbuffer;
*contentbuffer = 0;
iReadSize = 0;
}
while(0 != (iReadSize = stdFile.Read(contentbuffer, 4096)))
{
contentbuffer[iReadSize] = '\0';
csFileContent += contentbuffer;
*contentbuffer = 0;
iReadSize = 0;
}
now is better with my content of CString.
Still the part with parsing.
ragards
termal
|
|
|
|
|
So what does csFileContent contain at the end of it all?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
csFileContent is a CString, now is in there nothing like "ÌÌÌÌÌÌÌÌÌÌ"
this after i modify my loop for file reading, my post before.
And, i think on somethink like next loop over my filecontent.
LPCTSTR lpszContent = csFileContent;
while(*lpszContent)
{
lpszContent++;
}
thanks
termal
|
|
|
|
|
sorry, but this time, i really can't understand what you said...
i'm suspecting you no to be american as you say in your profile
|
|
|
|
|
hi,
i just ask is there any function to parse a fileline( with tab-separated), nothing else,
if yes, which one!
I never say im american!
regards
|
|
|
|
|
termal wrote: if yes, which one!
don't know, i used to do such read by hand...
termal wrote: I never say im american!
so you'd want to change this[^]
|
|
|
|
|
termal wrote: i just ask is there any function to parse a fileline( with tab-separated)...
Yes, use AfxExtractSubstring() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
thank you for Answer!
regards
termal
|
|
|
|
|
Something like this?
CString csFileContent = _T("index\tfname\tlname\tage\n1\tname\tlname\t20\n");
int curPos= 0;
CString ParsedStr = csFileContent.Tokenize(_T("\t\n"), curPos);
while (ParsedStr != _T(""))
{
ParsedStr = csFileContent.Tokenize(_T("\t\n"), curPos);
};
-- modified at 10:15 Tuesday 8th May, 2007
Fixed generic string consistency (thanks toxxct!)
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark, if you're using unicode stuff, use CStringW.
otherwise, with CString, prefer _T() macro around your litterals
look, you're even casting to LPCTSTR instead of LPCWSTR... your code is not consistant
and sorry if you received this multiple times, the servers had a bad time with me
|
|
|
|
|
|
Fixed but untested!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello,
thank you for help!
regards
termal
|
|
|
|
|
I'm getting the following errors when I build a dll in debug mode with the Runtime library setting to Multithreaded debug /MD
1>Linking...
1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strcat_s already defined in LIBCMTD.lib(strcat_s.obj)
1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _wcslen already defined in LIBCMTD.lib(wcslen.obj)
1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _wcscpy_s already defined in LIBCMTD.lib(wcscpy_s.obj)
1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __mbschr already defined in LIBCMTD.lib(mbschr.obj)
1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _iswctype already defined in LIBCMTD.lib(iswctype.obj)
1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _isxdigit already defined in LIBCMTD.lib(_ctype.obj)
However when I change the setting to Multithreaded debug Dll I no longer get the same error. can anybody tell me so.
P.S. this project used to compile on VC6 and no longer compiles once it is ported to VC2005.
|
|
|
|
|
Someone, somewhere, is linking with a singlethreaded runtime. Or with one statically linking the MFC. Or both.
Failure is not an option - it's built right in.
|
|
|
|
|
How to nail down the problem. IS changing the settign to use Multi threaded debug dll from Multithreaded debug the solution?
|
|
|
|
|
Try it!
If that was the problem, the errors will go away.
Just be sure to rebuild all (and maybe do the extra clean step: clean seems to do more than rebuild all does).
Failure is not an option - it's built right in.
|
|
|
|
|
You are linking with both the debug DLL (msvcrtd.lib) and debug static LIB (libcmtd.lib) versions of the CRT. You can only use one of those.
|
|
|
|
|
I am working on a product.I have a problem with one window(dialog)
The window appears in a smaller size.it hides all it controls.But when I resize the windoe it displays all its contents.after i close the window and reopen it the same sizeof the window is displayed.I mean the prvious size is restored rather than the optimum size of the window.
I want to know how can i correst this problem and give the window the right size at the time of its first display.It is been sqeezed to a very small size at the first time of display and i have to strech it to fit its contents.I think there is some small mistake that i did.
please contact me at gladiatorharsh@yahoo.co.in
i really need some help now.
thanks
Pankaj
|
|
|
|
|
pankaj0dm wrote: I want to know how can i...give the window the right size at the time of its first display.
Use SetWindowPos() or MoveWindow() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|