|
CPallini wrote: IMHO should be always
a[1] = 1; because a[i] = i++; is one statement.
What do you think about?
Well, I can agree on that in this context.
However, this can get very complex for the compiler. i++ is a statement that is parsed by the compiler and would generate almost the same instructions if the statement isn't too complex. Consider the following "complier complex" code:
a[i] = foo( i++ ); I would be surprised if the compiler assigned the array index matching i before the incrementation. It will usually put the variable on the stack prior to the function call and then increment it using the incremented i as array index when assigning. This is also how the VC6 compiler resolves the statement.
But...
the VC6 compiler will assign 1 to a[1] with the following statements:
i = 1;
a[i] = i++; This is a simpler statement and then the compiler gets smart, but it doesn't work the same way as in the example above, i.e. if the function call is replaced by simply incrementing the variable it won't assign the same array index. And this is for the same compiler.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: a[i] = foo( i++ );
Actually the VC6 compiler is honestly doing its job, because
foo( i++ ); is by itself a statement.
Anyway I agree on the overall point of view and I will never encourage somebody to write code like that.
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.
|
|
|
|
|
I am a new learner of VC++ and usually get good support from code project.
I am facing problem with Streams. I need some kind guidance of some senior programmer.
Problem is that I receive some data in a ISpStreamFormat object. I want to read this data into byte pointers but when I call IStream->Read() functions with a non-zero argument as desired no of bytes to read, read method fails returning STG_E_INVALIDPOINTER message. Only fixing a zero "0" as the desired number of byted does not result in Failure message but it reads nothing.
So please if anybody guids me how to read binary data from ISpStreamFormat stream.
Regrads
Zia
|
|
|
|
|
smzhaq wrote: ISpStreamFormat
Never heard of it. What sort of data are you reading ? Why are the standard C++ streams not sufficient to the task ?
It sounds to me like your stream does not have a proper input source.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thanx buddy
I was doing a blunder. In fact I was passing an uninitiallized pointer to the stream read function which was resulting in a bug.
Problem has been solved now. Thanx a lot
Regards
|
|
|
|
|
Hi, I'm using GetNamedSecurityInfo in a program I wrote to remove some registry keys from the Windows XP registry.
It seems to work on all the keys except for one. For some reason on one key it returns "The parameter is incorrect" as its error, yet I attempt to find this same key a moment later using the same path in a different function and it says that the key is valid.
Does anyone know what this "parameter is incorrect" might mean, besides it just having an invalid path name? All I'm passing it is a path, a pointer to an ACL to fill, and a pointer to a security descriptor.
Here's the code:
void RemoveAccessDenied(LPTSTR FullKey)<br />
{<br />
PSECURITY_DESCRIPTOR pSD = NULL;<br />
PACL pACL = NULL;<br />
<br />
GetNamedSecurityInfo(FullKey, SE_REGISTRY_KEY, DACL_SECURITY_INFORMATION, NULL, NULL, &pACL, NULL, &pSD);<br />
<br />
}
Thanks!
KR
|
|
|
|
|
Found it; spybot was denying the registry change based on my blacklist.
KR
|
|
|
|
|
BAD Spybot BAD! *swat*
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi,
I used to code in C++ but stopped for about a year, anyway I am back but have ran into a problem on my first project:
Any solution I now create doesn't work, when I try and build it it builds fine, but when I try and run it, I get the error that:
"Unable to start program "C:\\...projects\test\debug\test.exe". The system could not find the file specified"
I realise this means that it hasn't created the debug information, but it hasn't created the release information either.
Also I can Build Solution, and it says it is fine, but the Compile option is greyed-out and I don't know what to do.
Is there an option in MVC++EE when you can turn off compiling it until you do something?
Any suggestions?
Thanks,
Any reply is appreciated.
-- modified at 8:47 Monday 11th June, 2007
|
|
|
|
|
Blekk wrote: I realise this means that it hasn't created the debug information
No, it means it can't create the program - your compile is failing due to some other error.
Blekk wrote: Is there an option in MVC++EE when you can turn off compiling it until you do something?
No, there shouldn't be. If it doesn't show the option, it probably doesn't think the option is valid, for some reason.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Ok thanks but I even just tried compiling this in a new solution and it didn't work:
#include <iostream>
using namespace std;
int main()
{
cout<<"This should work...";
return 0;
}
Any ideas?
|
|
|
|
|
I have a application in which I have to read a text file with more than 1 hundred thousand lines. I am having trouble with reading file and replacing the text in file. I want to read file's content and display it in Rich text edit quickly, and when I replace some text by other texts, the process must do quickly. I have tried using Notepad to read and replace some text, but it takes about 10 to 15 minutes to finish the works
duc an
|
|
|
|
|
|
hi all
please .. Can i print the output of program to the printer directly
please tell me
thank's all
<br />
#include <iostream.h><br />
<br />
main ()<br />
{<br />
cout <<"Hi all .. That's Me";<br />
<br />
return 0;<br />
}<br />
<br />
-*-*-*-*-*-*-*-*-*
To Be Or Not To Be
(KARFER)
-*-*-*-*-*-*-*-*-*
|
|
|
|
|
*if* your printer is connected to LPT1 you might be able to do the following:
<br />
ofstream printer;<br />
printer.open("LPT1");<br />
printer << "Hello World!" << '\n';<br />
And when your done streaming text to the printer you can try sending a control character of 0xC which was the old ASCII Form Feed[^] or (FF) character.
Best Wishes,
Randor (David Delaune)
|
|
|
|
|
Hello Friends,
I am been using CSocket in my application. But i want to know is CSocket a blocing socket or non-blocking socket, and what are the differences between them ?
Girish
Software Developer
|
|
|
|
|
Girish601 wrote: But i want to know is CSocket a blocing socket or non-blocking socket, and what are the differences between them ?
Hmmm MSDN->CSocket[^]
CSocket Class MSDN wrote: A CSocket object also provides blocking, which is essential to the synchronous operation of CArchive. Blocking functions, such as Receive, Send, ReceiveFrom, SendTo, and Accept (all inherited from CAsyncSocket), do not return a WSAEWOULDBLOCK error in CSocket. Instead, these functions wait until the operation completes. Additionally, the original call will terminate with the error WSAEINTR if CancelBlockingCall is called while one of these functions is blocking.
|
|
|
|
|
See Windows Sockets: Blocking[^]
CSocket is a high-level wrapper for a socket (SOCKET). To you, it's always blocking. Whether
the underlying SOCKET is in blocking mode or not is handled by the CSocket implementation.
For a non-blocking socket you can use the CAsyncSocket class or use Winsock APIs directly.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hey there. Can anybody tell me why, when you create a dialog app in VS2005 if you right-mouse click on the dialog in the resource editor then "Add Event Handler" menu option is greyed out? I want to be able to add OnInitDialog and OnPaint handlers to this dialog but cant!
If i drop a button control on the dialog through, and right click on that, then that works!!
thanks in advance.
|
|
|
|
|
To add non-control message handlers, you have to go to the source file, and place the cursor on the closing message map macro, and then go to the properties pane. At that point you hould be able to add the handler for that message.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: To add non-control message handlers, you have to go to the source file, and place the cursor on the closing message map macro, and then go to the properties pane. At that point you hould be able to add the handler for that message.
[sarcasm] Clearly that's so much easier than VS6[/sarcasm]
Thanks for the tip, not that I will remember it, just seams easier to write it out.
|
|
|
|
|
Yeah... This goes a long way to reinforce Microsoft's claim that they are eager to support their C++ developers. The 2005 IDE sucks if you're a MFC programmer. I seriously doubt that ORCAS would add any usability for us...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hey John! No way, i would have never have found that out.. Thanks a million..
It all becomes clear (as mud!)
|
|
|
|
|
:omfg:
--
Now with chucklelin
|
|
|
|
|
John Simmons / outlaw programmer wrote: you have to go to the source file, and place the cursor on the closing message map macro, and then go to the properties pane.
You can also just click anywhere within the class definition in the .h file, and then go to the properties pane.
|
|
|
|