|
#include <stdio.h>
namespace ConsoleApplication1
{
class Program
{
public:
void function01()
{
printf("Hi, I am function 01, now calling function 02\n");
function02();
}
void function02()
{
function01();
}
};
}
void main()
{
ConsoleApplication1::Program p;
p.function01();
}
The behavior would be exactly the same.
It will do function calls recursively and die with a stack overflow.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi Superman,
That was cool, thanks! Please wait while I vote your reply
However, is there some way to prevent the stack overflow funda? I hope implementing the ForLoop concept will help.
for (int i=0;i<=10;i--);
Will this overcome stack overflow? Note, that I have declared post decrement operators at the end of the loop. This shall continue execution on and on without any limitation. Will this crash the program?
Always ready to help (if possible, often I am a NooB!) and be helped!
|
|
|
|
|
Please tell me the desired output.
The stack overflow occurs because you are called one function from the other endlessly.
function01 called function02 which calls function01 which calls function02 and soon.
There is no end to this.
And since function calls use stack space, it will go on till it runs out of it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
|
Hey Superman,
Thanks for your help men... Can you give me the code for copying the current executable to a desired location? Something like this:
When I execute the program, it should copy itself to a specific desination directory, like C:\\folder\\program.exe. I know that for this I have to get the path of the executable, but I cant code this in C++. Please help me friend.
Always ready to help (if possible, often I am a NooB!) and be helped!
|
|
|
|
|
|
Please review this users history as his past posts will show his intentions are malicious, he should not be given snippets of code that can help further his endeavor to potentially harm computers.
Again, I implore you to review his past posts, his intentions are clearly outlined and documented, at one point he even admitted and conceded to drop his questions of malicious intent, but it appears he switched from .net to C++.
|
|
|
|
|
Wow!!! That is some heavy stuff that happened back then.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Great One Dude!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Rajdeep.NET wrote: ...I have to get the path of the executable, but I cant code this in C++.
Why not? Don't you have access to argv ?
"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
|
|
|
|
|
If you read through the messages in this thread you'll get an idea of his level of knowledge...
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Hi, I have a problem running this code, it doesn't do what it's supposed to do. Can anybody give me a hand? thanks
int main(){
char answer='S';
while (answer=='S'){
printf("another?: ");
scanf("%c",&answer);
}
return 0;
}
|
|
|
|
|
Denis J. González wrote: it doesn't do what it's supposed to do
That depends on what you're trying to do.
And you haven't mentioned what the problem is.
All I can say now is that you might need an fflush(stdin) after the scanf
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
That did it! great! thanks!
what does fflush(stdin) do?
|
|
|
|
|
It clears the standard input buffer, in this case the keyboard buffer.
When you key in a character and press enter, the keyboard buffer will contain the keyed in character and the carriage return (enter key). Only the keyed in character is taken into the buffer (answer). So now the carriage return has to be cleared, otherwise the next scanf will automatically take that.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
When I attempted to import 'MS-WORD' and 'MS-EXCEL' as MFC type lib, an object file link error occurred.
What should I do if I want to use 'MS-WORD' and 'MS-EXCEL' together?
thank you ...
|
|
|
|
|
Hows about you give some more detail about those errors....
Personally, I use #import[^] to make external COM libraries available in my code. Works very well.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I guess WORD and EXCEL will have different namespaces which should help you resolve the issue.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
some namespaces tips?
#import "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE" no_namespace
#import "C:\\Program Files\\Microsoft Office\\Office11\\MSPPT.OLB" no_namespace
Following is error message:
error C2367: 'IFilter' : redefinition; different uuid specifiers
..
..
..
modified on Tuesday, June 16, 2009 1:24 PM
|
|
|
|
|
Do not use no_namespace .
I really don't know the exact namespace given to excel and powerpoint.
But assuming it is excel and ppt, you now access the IFilter or any other interface for that matter as excel::IFilter and ppt::IFilter .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I'm pretty new to VC++ and need to write a fairly simple barcode application that reads and writes data to a file. The file is then uploaded using activesync for processing. Can anyone point me in the right direction in terms of dialog based / window based and file input / output?
thanks.
|
|
|
|
|
Hey
Well, if you need to use forms I would suggest for you to use C# instead.
If there are things I have to do in C++ than you can always create a DLL with exports or COM DLL... depends on your requirements.
Anyway, if you want to create forms in C++ I would suggest using MFC (just follow the wizard in visual studio). Explaining exactly what is going on over there is a bit big for a that forum, but there are plenty of articles out there. Besides, I always believe that some trial and error is a good experience with new environments.
about reading and writing a file, you have several options:
- If you're using MFC, the easiest thing is to use MFC's CFILE class (I hardly use MFC so I can't really tell you much about that class, but I am sure it is easy to use this class).
- Another option is to use CATLFile, which is a class that literally wraps WIN32's read/write functions.
- You can use win32's read/write functions:
CreateFile()
ReadFile()
WriteFile()
you can see their signatures in MSDN (F1). There are some options for these functions and MSDN explain what each option means, if it gets a bit complicated, just ask...
- If you want a portable code (that will compile on windows and unix as well) you can use plain good old C functions: fopen() fread() fwrite().
|
|
|
|
|
Hi everybody
Can anyone please explain what is the difference between OLE and a COM?
I know that COM derives from OLE, but what OLE component lacks that doesn't make it a COM component?
In other words, I know what COM is, and I created several COM servers in C++, but I don't quite understand what is OLE...
Thanks A LOT in advance!
|
|
|
|