|
Max++ wrote: buffer="aaa,bbb,ccc";
str = buffer.GetBuffer (10);
buffer.ReleaseBuffer ( );
That won't work. Once you use ReleaseBuffer, the pointer isn't valid.
Since you're using a single character delimiter, you could use AfxExtractSubString instead.
Steve S
Developer for hire
|
|
|
|
|
try this, if satisfies your need. Use sTemp to assign to array.
int nIndx=0;
CString sTemp;
while(nIndx != -1)
{
int nTemp=s.Find(",",nIndx);
if (nTemp==-1)
{
if (nIndx !=0)
{
sTemp=s.Mid(nIndx,(s.GetLength()-nIndx));
}
break;
}
sTemp=s.Mid(nIndx,(nTemp-nIndx));
nIndx=nTemp+1;
}
|
|
|
|
|
Use AfxExtractSubString() instead.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Example below which is helps to make use of strtok
eg.
char *szSep="\";
char *sDest=NULL;
char *szChar=NULL;
CString sString="Hell0\Word";
sprintf(szChar,"%s",sString);
sDest=strtok(szChar,szSep);
kk
|
|
|
|
|
don't mix C and C++
there are whatever you want in the C++ libraries.
also, read the previous answers...
|
|
|
|
|
Karthikeyan .g wrote: sprintf(szChar,"%s",sString);
You don't expect this to work, do you?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You do NOT want to pass in a CString's buffer to strtok. strtok changes the buffer it operates on. Thus, if you pass in the buffer returned from GetBuffer, it will change it and the original CString object will be invalidated (that is, the data will be changed) when you call ReleaseBuffer. Looking through what you want to do, just use something like:
void Split(CString strText, CString strSeparators, CStringArray& strArray)
{
int start = 0;
while (start >=0 && start < strText.GetLength())
{
int stop = strText.Find(strSeparators, start);
if (stop < 0 || stop > strText.GetLength())
stop = strText.GetLength();
strArray.Add(strText.Mid(start, stop - start));
start = stop + 1;
}
}
The strArray parameter will hold the values you are looking for.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
hi,
I have got blob file, and i want to insert that into image/blob column of database, how can i do that programmatically in C++/MFC.
Warm Regards,
Mushq
|
|
|
|
|
Is this With Access, Microsoft SQL, or MySQL?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
It is SQL Server and Oracle.
Warm Regards
Mushq
|
|
|
|
|
|
See here for starters.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I want to remove the Titlebar of a SDI FrameWnd class.
could you please tell me which style should I specify?
-Sarath.
The more you can dream the more you can do - Michael Korda"
|
|
|
|
|
Remove the style WS_CAPTION
|
|
|
|
|
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style = WS_VISIBLE | WS_THICKFRAME;
return TRUE;
}
I specified the above code in the precreate Window function. But it is not working for me.
-Sarath.
The more you can dream the more you can do - Michael Korda"
|
|
|
|
|
Use ModifyStyle(WS_CAPTION,0); in OnCreate instead.
|
|
|
|
|
Thanks for your reply.
we need add one more tweak to avoid painting problems.
The following code worked fine for me.
ModifyStyle(WS_CAPTION,0);
SetWindowPos(NULL, 0, 0, 0, 0,
SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|
SWP_DRAWFRAME);
-Sarath.
The more you can dream the more you can do - Michael Korda"
|
|
|
|
|
Sarath. wrote: SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE| SWP_DRAWFRAME);
you can mention this as third parameter of ModifyStyle . You need not call SetWindowPos
|
|
|
|
|
I forgot it Thanks
Anyway those flags need to be called
-Sarath.
The more you can dream the more you can do - Michael Korda"
|
|
|
|
|
Sarath. wrote: But it is not working for me.
Which means what exactly? Does the frame window still have a titlebar?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi
Application in release version is working fine but crashing in debug version.
I think its because of ASSERT statement.
Does any one has a clue?
TIA
|
|
|
|
|
Use your debugger to locate more precisely the problem.
EDIT:
Yes, ASSERT wroks only in debug mode but if something asserts, it means that something is going wrong.
|
|
|
|
|
Where it is crashing ?
Please show the code where it is crashing
RinuRaj
|
|
|
|
|
Its a switch statement with diff cases:
pseudo code:
switch(text)
{
case1:
Do something...;
case 2:
Do something..;
default:
ASSERT(FALSE);
}
Its going to default case and then assert statement is excuting and it crashes here.
Its giving error
"A breakpoint has been reached.
(0x80000003) ocurred in application at location 0x7c901230"
|
|
|
|
|
Jacqi123 wrote: Its giving error
"A breakpoint has been reached.
(0x80000003) ocurred in application at location 0x7c901230"
Possibliy, you are pressing Abort Retry button on Assert dialog.
Assert doesn;t necessarily lead code to crash. Its just indication, thats some thing going wrong.
What happens,if you use Ignore button on assert dialog? As its not crashing in Release, should not crash in debug.
And then, check code flow, why code is going to default case, where it should not go, as per your coding.
-- modified at 8:08 Thursday 7th September, 2006
-- modified at 8:39 Thursday 7th September, 2006
|
|
|
|