|
int i=7; printf("%d",i++ * i++ ); output is 49 ; how is this possible ?? i think it should it be 56 . if it is 49 how can this be justified
|
|
|
|
|
First off, if your using the ++ operator and passing the value as an argument you should prefix not postfix the the operator ( ie. ++i ) else the value is incremented after the statement is executed - see the c++ documentation for more details.
Secondly, ur incrementing the value twice - so you'll end up with a result of 64 being printed (8 x 8).
Simple really...
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
Gavin Taylor wrote: so you'll end up with a result of 64 being printed (8 x 8).
But he's saying the output is 49 .
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Thats my point, he's multiplying 7 * 7 and the ++ is getting executed after the main statement.
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
Short answer: don't do that.
Long answer: Having more than one ++ or -- operating on the same variable in the same expression is bound to expose an implementation detail and give unexpected results. It's the same reason that you shouldn't do this:
int a = 7;
int b = a++ + ++a;
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|
Michael Dunn wrote: b = a++ + ++a;
*shudder* That just kinda makes me feel dirty looking at it
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
The ++ operator does take affect until the next sequence point is reached, in this case the semicolon at the end of the statement, so i is not incremented until after the function call.
But as Michael said, don't use more than one ++ or -- on a variable in a single line - you are violating the C++ standard, which states that no variable can be modified more than once between successive sequence points.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I have created a dll file with dialog box. Dll I am using in Visual Basic .NET. How can I display the dialog box so the user could not switch back to the original form without closing the dialog box? Like system Open or Save dialog boxes...
1. For displaying my dialog box from DLL I am using following code:
DialogBox(_hInstDLL, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)MainDlgProc);
With this code the user could change focus to the application window in Visual Basic .NET.
2. I have tried also send an handle of application window:
DWORD WINAPI ShowConfigurationDialog (HWND hwndParent, ...)
{
...
DialogBox(_hInstDLL, MAKEINTRESOURCE(DLG_MAIN), hwndParent, (DLGPROC)MainDlgProc);
}
And from Basic:
ShowConfigurationDialog(Me.Handle.ToInt32, ...)
In this case the dialog box will not be displayed at all and DialogBox returns with 0.
Thanks, Roman
|
|
|
|
|
Ooo , I did not pass the handle's value but the handle's address!
I have mistake in declaration:
ShowConfigurationDialog(ByRef ParentHWND, ...)
Right one:
ShowConfigurationDialog(ByVal ParentHWND, ...)
|
|
|
|
|
In preparation for retro-incorporating the MiniExcel class into a number of my projects I've set up a practice project in order to get familiar with the class. I'm in VC++ 6.0 and the project is an MFC exe. I've put the mexcel.cpp and mexcel.h files in the base project directory. I've added both files to the project. I've #included mexcel.h in stdafx.h and also, for good measure, in the view doc file. The class shows up in the Classes tab, though it doesn't show up in ClassWizard after a rebuild of the CLW file.
I've declare an object of class CMiniExcel as a local variable inside a button message handler. When I go to compile I get four errors. The first three indicate that the class is unknown. The fourth is:
fatal error C1010: unexpected end of file while looking for precompiled header directive
Additionally I've noticed that instead of being placed in the DEBUG directory the system has created a directory with the projects base name followed by ___Win32_Debug
Am I using a class that needs to be modified to work under MFC or am I overlooking something else.
Thanks,
Lilith
|
|
|
|
|
|
Sorry, still no change. But thanks nonetheless.
Lilith
|
|
|
|
|
blockquote class="FQ"> Michael Dunn wrote: Fixing the PCH settings may take care of the other errors
A revision to my previous reply. I've gotten past the error but have gotten four warnings of the same type. It compiles and links. But I'd be interested in suppressing the warnings if possible. The error/warning is
C4786
'identifier' : identifier was truncated to 'number' characters in the debug information
The identifier string exceeded the maximum allowable length and was truncated.
It doesn't appear to be an identifer as much as it's an expansion of a vector template. Since namespace is specified as std that gets included in the expansion to the point that the entire line is over 300 characters.
Lilith
|
|
|
|
|
Lilith.C wrote: C4786
'identifier' : identifier was truncated to 'number' characters in the debug information
That's harmless, you can turn it off.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Ford, what's this fish doing in my ear?
|
|
|
|
|
Hello.
When creating a MDI application (with MFC AppWizard VC++ 6.0) you have the choice of excluding the maximize/minimize boxes for the child frames.
When creating my MDI app, I chose to not have the maximize/minimize boxes, but to have the child frames start in 'maximize mode'. However, when the child frames are viewed in 'maximized mode', the non-themed minimize and maximize buttons are still drawn.
Is there a way to remove or at least disable the non-themed maximize/minimize buttons?
-----------------
Genaro
|
|
|
|
|
|
I tried that in the BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) function. However, that only removes the boxes if the child frame is not in 'maximized mode'. What function should I edit/override to also remove the non-themed buttons (those show when in maximized mode)?
Thank you very much,
-----------------
Genaro
|
|
|
|
|
|
Thank you very much for the help...
I am almost there. The only thing is that removing the WS_SYSMENU also removes the [x], which I would like to keep. Is it possible to do that?
Thanks,
-----------------
Genaro
|
|
|
|
|
picazo wrote: WS_SYSMENU also removes the [x],
Yeah that's why I told it's dirty.
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I want to enable and disable a dialog control(check box,edit box) from another dialogue and a global function...
How can i???
|
|
|
|
|
|
God Bless u too!
cheerz bro!!!!!
rateep
:"faith, hope, love remain, these three.....; but the
greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
or use GetDlgItem(ID_OF_THE_CONTROL)->EnableWindow(BOOL)
eg:
GetDlgItem(IDC_CHECK_DISABLE_HSC)->EnableWindow(FALSE);
cheerz!
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Hello everyone!
Alright... here's how I want to get my bitmap:
res://Graphics.dll/RT_BITMAP/101
That doesn't seem to work right, neither in my program nor in Internet Explorer (yes, I'm plugging the full path with forward slashes and everything)...
Does anyone know what's wrong? I didn't compress my DLL...
Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|