|
Hello
I have a char * m_Str which is equal to "Test A"
I have another char* Str which is equal to " of"
I want m_Str to be equal to "Test of A"
So I need to put " of" into m_Str beginning in position 4
so my function could look like this:
bool Insert(char * Str, int Index)
where index = 4 and Str = " of"
thanks,
Lino
|
|
|
|
|
you should pass a parameter to the function to know the maximum number of characters the destination buffer can contain.
I submit another way, with CString, but you will be able (i hope) to adapt it to you problem.
<font color=#0000FF>void</font> myClass::Insert (CString Str, <font color=#0000FF>int</font> Index) {
CString strTmp = m_Str.Left(Index);
strTmp += Str;
strTmp += m_Str.Mid(Index);
m_str = strTmp;
}
TOXCCT >>> GEII power
|
|
|
|
|
it's a char* not a string...and I have to leave it a char* so I don't think you're solution will work.
|
|
|
|
|
you have to reconstruct a new char* string.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
useloops to find the position where you want to "insert" the new string...
after that, use malloc, strcpy, strcat, ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
lino_i wrote:
it's a char* not a string
but the functions exist also for char* strings... use your brains guy...
TOXCCT >>> GEII power
|
|
|
|
|
instead of asking me to adapt your solution to my problem just provide what I and other on the board are looking for if not then do not reply...keep your opinion to yourself.
don't reply to look like a hot shot...
get a life and in the future do not reply to any of my posts...your responses are not welcome nor needed.
|
|
|
|
|
as you like, i thaught i was helping you in giving you a piece of code... visibly, you don't need it.
i just want to add : CODEPROJECT IS NOT AN HOMEWORK SITE !!!
TOXCCT >>> GEII power
|
|
|
|
|
no you were not helping...and wake up this is a message board you should only be responding if you genuinely want to help. NO ONE IS FORCING YOU SO IF YOU DON'T HAVE PATIENCE AND ARE FRUSTRATED AT WHAT MAY SEEM TO YOU AS ROUTINE CODING THEN YOU SHOULD OPT OUT OF RESPONDING.
This has nothing to do with homework IT IS A MESSAGE BOARD WHERE YOU COME TO GET HELP FOR ALL!!! (Homework, leisure, work...whatever it may be)
so shut it!
|
|
|
|
|
|
are u laughing at your own ignorance about what a message board is for?
|
|
|
|
|
you cannot directly insert chars ( or sub string ) in an existing string, you need to rebuild the a string with the diffeernt parts.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
One way would be:
char *m_Str = "Test A";
char *Str = " of";
char szResult[10] = {0};
strncpy(szResult, m_Str, 4);
strcat(szResult, Str);
strcat(szResult, &m_Str[4]);
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
Does anyone know how to hide a window's title bar on a Win32 app?
Thanks in advance!
|
|
|
|
|
Use SetWindowLong API call and pass in a modified windows style. Look up the various WS_XXX window styles in MSDN. I *think* (off the top of my head) that you want to remove the WS_CAPTION style. But you may also have to remove others.
Once you have modified the style you need to call SetWindowPos like so:
::SetWindowPos( hwnd_, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE );
SWP_FRAMECHANGED is the critical part that causes Win32 to refresh the window properly.
You can use GetWindowLong(GWL_STYLE) to get the orginal window style and then modify that accordingly.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Hi,
Thanks for the help but I cant make it work. I can remove other WS_*** styles but not WS_CAPTION. For some reason my window has a caption bar by default. Do you know any possible reasons why?
Thanks again!
|
|
|
|
|
You might have to remove other window styles that would also cause Windows to draw a caption bar. The ones that come to mind are WS_MAXIMIZEBOX , WS_MINIMIZEBOX , WS_OVERLAPPEDWINDOW and WS_SYSMENU , but there may be others as well.
|
|
|
|
|
How to change font color and backround color C++ program
|
|
|
|
|
In CView::OnDraw(CDC* pDC) or using the CDC *pDC=GetDC() member function
//To Set font color
COLORREF oldCol=pDC->SetTextColor (RGB(0,0,255));//Blue Color
// use font to draw stuff
//.....
pDC->SetTextColor (oldCol);//restore old font color
//the same Way to set back ground color
COLORREF OldbkColor=pDC->SetBkColor (RGB(0,0,0));
//Do your drawing
//......
//if U want to restore BK Color
pDC->SetBkColor(OldbkColor);
|
|
|
|
|
what about dialog based programs ?
TOXCCT >>> GEII power
|
|
|
|
|
see this arrticles
http://www.codeguru.com/Cpp/W-D/dislog/background/article.php/c1849/
http://www.codeguru.com/Cpp/W-D/dislog/background/article.php/c1895/
|
|
|
|
|
For dialog based programs, you will have to override a handler WM_CTLCOLOR. This can change the colors of all the controls on a dialog and the color of the dialog itself.
<marquee> STUCK STUCK STUCK STUCK
Stuck to Programming through an unbreakable bond
My Articles | My Blog
|
|
|
|
|
How to change font color and backround C++ program
|
|
|
|
|
Where you want change color : in control, in view, int title bar ... ?
|
|
|
|