|
Member 3220373 wrote: and I wanted to copy a substring from a main string
e.g:;-- String1 :- "Visual c++ is Great..";
subStr = "c++";
how can I get this???
I have used strstr() function to get substring..
but it returns first occurance and full sunstring follwing that,,
plz help me..
I need it dedly..
I used another method to get it..
but its lengthy...
Using CString ...
First use CString::Find and then CString::Mid to extract substring.
Using std::string
First use std::string::find and then std::string::substr .
|
|
|
|
|
Thanx for ur reply..
I forget to tell u that..
I m not using MFC classes or function.s;;;
Its just Win32 console application.....
can i use CString in console application????
plz reply..
|
|
|
|
|
Member 3220373 wrote: Its just Win32 console application.....
can i use CString in console application????
Quite easy to use MFC in console application. First link to MFC libraries and then call AfxWinInit and a global CWinApp instance, sample code...
CWinApp app;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr << "Fatal Error: MFC initialization failed" << endl;
return 1;
}
And if you are going to use MFC just for this purpose, I would discourage you from doing so, instead use std::string .
|
|
|
|
|
Thanxxxxxxxxxxxxxxxxxxxxxx...a lot.....
it works....
|
|
|
|
|
Member 3220373 wrote: Thanxxxxxxxxxxxxxxxxxxxxxx...a lot.....
Welcome!
|
|
|
|
|
Member 3220373 wrote: Its just Win32 console application.....
Then you can use strncpy() or memcpy() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hello All,
I am working on project in VC++ which uses ado library objects to access SQL Server database and insert data into it.I am using Recordset objects.When I try to get the name of field of recordset which is of table it crashes on the following line:
_bstr_t name=field->GetName();
This crashes due to _bstr_t data type when viewed in call stack.
How to solve this problem is this a memory leak in _bstr_t???
Plz help me out.....
Thanks
|
|
|
|
|
amrit1123 wrote: _bstr_t name=field->GetName();
What does GetName() return, is it a valid string?
|
|
|
|
|
Yes ,GetName()of field object returns a valid string i.e name of column.The function has a return type of _bstr_t and i stored thefeturned string into _bstr_t type variable.e.g.
_bstr_t name=field->getName();
But the program crashes and unable to store the returned string into name variable.Plz help me out ...
Thanks
|
|
|
|
|
Yes the GetName() returns some valid string but it failed to store the returned _bstr_t string into name varaible which is also of _bstr_t type which i got while debugging the GetName() function call.
The Program shows problem while allocating memory for _bstr_t type is there any memory leak in using _bstr_t type.As i know _bstr_t does memory management by itself and we dont have to free any memory allocated.So I am unable to understand the reason why it crashes when the function return type and the variable in which it is being stored are of _bstr_t type and function is returning a valid not null string..
Can u help me out because my application is crashing coz of this.......
Waiting for ur reply
|
|
|
|
|
Hello,
Previously my code was in Visual C++ 6.0, where ON_MESSAGE was running fine, with me religiously fulfilling all its requirements, i.e. return type was LRESULT, parameters to my function were WPARAM and LPARAM. But the same code, when I converted to VS 2005, the program only compiles and the DLL gets created, but ON_MESSAGE macro seem to be failing? My user defined message does not get called at all. Is a change needed in how I write ON_MESSAGE macro? Please suggest the remedy.
thanks in advance.
Software Developer
Sanjay Khapre
|
|
|
|
|
SanjaySMK wrote: My user defined message
How do you create your user defined message?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi,
either by using enum or by # define e.g.
enum
{
WM_DOCLISTDCLICKED = WM_APP+1,
WM_DOCLISTCLICKED = WM_APP+2
};
OR
# define WM_DOCLISTDCLICKED WM_APP+1
# define WM_DOCLISTCLICKED WM_APP+2
Software Developer
Sanjay Khapre
modified on Friday, January 2, 2009 7:42 AM
|
|
|
|
|
Well, i was just curious that whether you was using the obsolete WM_USER for defining you messages. The ON_MESSAGE is changed in VS 2005[^]. Well, could you please post your message map and relevant code snippet?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Has anyone of u used this article owner draw menu?
If anyone used it and know how to solve my problem, Please help - Highly Appreciated
http://www.codeproject.com/KB/menus/bcmenu.aspx
Hi, when i tried this owner draw menu, why did the DrawItem function are not being triggered??
Because when i tried other owner draw menu, even if i did not click the menu item[on the menu bar] it will trigger the DrawItem.
I'm trying to change the font's color of the menu item text[on the menu bar]
I already succeeded to change the font color of the submenu items.. which it will trigger DrawItem function when i click it.
Thanks,
KH
good
|
|
|
|
|
Hi All
How can i Compare two file data line by line?Plz help me
|
|
|
|
|
open both files using ifstream
call getline on both files
use strcmp or wcscmp to compare.
« Superman »
|
|
|
|
|
What do this code do ?thanks
for (i = 0; i<4; i++)
c_sum ^= sBuffer [i];
|
|
|
|
|
What about documentation [^]?
BTW the posted code is computing the checksum of the array content.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Friday, January 2, 2009 9:24 AM
|
|
|
|
|
^ is the XOR operator.
« Superman »
|
|
|
|
|
From the MSDN:
&& (and)
&= (and_eq)
& (bitand)
| (bitor)
~ (compl)
! (not)
!= (not_eq)
|| (or)
|= (or_eq)
^ (xor)
^= (xor_eq)
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
|
how to draw bitmap using CDC
Ashish
|
|
|
|
|
You can use of this code on the paint event or earse event(I didnt test but I think it works).
#include "Atlimage.h"
CImage m;
m.Load(_T("c:\\1.jpg"));
m.BitBlt(0,0,800,600);
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I want only CDC class to use
Ashish
|
|
|
|