|
Loveprogramer wrote: char *from = "c plus plus";
char *to = "oooooooooooooooo";
Here "from" and "to" are constant strings exactly, so the codes below would be mistake.
"*to++ = *from++".
If you declare "from" and "to" as array of string, your program would work fine.
Just like:
char from[] = "c plus cplus";
char to[] = "oooooooooooooooooooooo";
|
|
|
|
|
carter2000 wrote: Here "from" and "to" are constant strings exactly, so the codes below would be mistake.
Not true; declaring a string as char* str or char str[] yields the same result.
|
|
|
|
|
Maybe I made something wrong, but it just works fine in my computer. My compiler is VS2008.
|
|
|
|
|
foot - mouth - brain!
I must remember brain comes first.
|
|
|
|
|
I think the problem is probably in the following statement: while((*to++ = *from++) != '\0'); . The C++ language specification for the assignment operator states "The assignment operators return the value of the object specified by the left operand after the assignment." i.e the to pointer. Thus in the above statement the comparison is done with the next element of the to array, which being longer than the from array, contains the character 'o'. The while loop is now out of control as it is copying garbage. Rework your loop so that it tests the source array element for '\0', rather than the destination.
[EDIT]Sorry, I got this wrong, the result of the expression is to before it gets incremented, hence it is correct.[/EDIT]
modified on Monday, October 12, 2009 5:45 AM
|
|
|
|
|
Well, what have you discovered for yourself?
Does that copy_pointer loop die on the first time it does something?
When it hits a NULL?
Does it die if to is a dynamically created variable?
ie,
char *buf = new char [128];
copy_pointer (from, buf);
delete [] buf;
I'm 90% sure I know what's wrong, but I'll wait for you to run these tests and see if you can find out for yourself.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Try this
char from[] = "c plus plus";
char to[] = "oooooooooooooooo";
instead of
char *from = "c plus plus";
char *to = "oooooooooooooooo";
|
|
|
|
|
Hi all!
Why this Function (http://msdn.microsoft.com/it-it/library/dd758083%28en-us,VS.85%29.aspx) return always E_FAIL?
Example of use:
ULONG eat = 4;
pUI->ParsePropertyName(_T("Size"), &fmtid, &pid, &eat);
Return E_FAIL when have to return the FMTID/PID correspondent of Property...
Please Help!
|
|
|
|
|
What is the HRESULT value that is returned?
The return value will probably give you a better idea about what is wrong.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
HRESULT is 0x80004005
I have printed returned HRESULT in Hexadecimal...
|
|
|
|
|
I have resolved the problem
the ULONG parameter must be 0... thanks anyway
|
|
|
|
|
But on Windows Vista don't work!
Grrrrrrrrrrrrr
|
|
|
|
|
Hi,
I have a CFramewnd from which I create CDialog modeless flavor..
In the CDialog one of the controls is a CRicheditctrl which I populate with data
My problem the data from the Cricheditctrl is never displayed
The Dialog remains Solid Gray which is the same Background Color as the CFrameWnd Background
It just occurred to me the when I get OnPaint Notfication for the CFrameWnd I probably paint the Cdialog
Which lies at the Upper Left hand corner of the CFameWnd
However When I hit a breakpoint on the CDialog::Create I also set a BreakPoint on the OnPaint notfication handler
it never gets executed
When I change the Background color of the CFrameWnd to Red the CDialog displayes as Red Too...
Any Ideas ???
thankx
|
|
|
|
|
Check to see if you have called the AfxInitRichEdit[^] function before displaying the dialog.
If not, call the function in the InitInstance override of your CWinApp derived class.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
Have that
Funny thing I have a Modal dialog Box with 2 single line edit controls which displays properly
I am thinking of coding my own Create for the CFrameWnd with the "WS_CLIPCHILDREN" style
I am thinking this would go CFrameWnd contructer...
|
|
|
|
|
Hi!
I've a problem localizing MFC error messages. Currently, I need to change AFX_IDP_PARSE_INT_RANGE which is used in DDV_MinMaxInt to display error message when int value is out of range.
I added the string to the string table of my application, but it doesn't seems to change the error message in MessageBox. Rebuilding doesn't help.
I've checked the code, an in MyProject.rc MFC wizard added:
STRINGTABLE
BEGIN
AFX_IDP_PARSE_INT_RANGE "Значение может быть от %s до %s"
END
And, as I said earlier, the MFC dialog is shown with english (default) version of this string.
Please help me with this problem,
I need to release the project tomorrow morning!
Thank you,
Andrey Yanov
|
|
|
|
|
_Andrew wrote: Please help me with this problem,
I need to release the project tomorrow morning!
To borrow a quote, lack of planning on your part does not constitute an emergency on ours.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi
I want to make a loading message box which disappears once the loading was finished.
In order to do that I decided to use the function DialogBox in order to create a modal dialog, however, I couldn't find a message that indicates that dialog has finished drawing itself.
I want to start the loading sequence right after the dialog and the message of "loading" appears on the dialog.
Any suggestions ?
I would like to use a dialog in order to easily make a nice loading message.
Thanks a lot,
Clint
|
|
|
|
|
In wich ambient you are doing this? MFC?
In that case you can take OnInitDialog event or.. WM_INITDIALOG
|
|
|
|
|
I tried WM_INITDIALOG, but it happens before the dialog has finished drawing itself, so the message doesn't appear.
|
|
|
|
|
|
Also WM_PAINT is not good, it happens during the drawing of every control.
|
|
|
|
|
Hi all... how i can convert a Property name to a PROPERTYKEY structure (FMTID/PID) by the name?
Example:
From Registry i take: HKEY_CLASSES_ROOT\*\InfoTip
than in my case, the result is: "prop:DocTitle;Type;Size;FileVersion;FileTitle;ProgramDescription"
I have written a function to get sequentially property by property... so i have:
DocTitle
Type
Size
FileVersion
FileTitle
ProgramDescription
I want to translate the correspondent PROPERTYKEY structure (FMTID/PID) or otherwise translate this string to the correspondent replacement as Windows Explorer do.
Any suggestion is appreciated. Thanks in advance!
|
|
|
|
|
Hi,
I need to know (source code will be more helpful) how can i filter a list of files which will be displayed in files explorer (like windows explorer) with its extension.
For example when i click on desktop (in tree control in the left) the list of files (ONLY a specified type of files (extension i.e doc...)will be displayed not all files in this directory).
I use :
- CTreeCtrl
- CListCtrl
My application is a SDI MFC .
I'm waiting for response, please help.
|
|
|
|
|
khaliloenit wrote: For example when i click on desktop (in tree control in the left) the list of files (ONLY a specified type of files (extension i.e doc...)will be displayed not all files in this directory).
See the description of FindFirstFile()[^] for details.
|
|
|
|