|
It is not really obvious if recursion needs multiple return statements.
It all really depends on the logic being implemented.
So if you've implemented it and are not getting the expected results, posting the relevant code should get the good people here to help you figure out the problem.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
You may be right that I am not sure about the "returns".
But debugging in IDE which lacks debugger you kinda flying blindfolded.
I'll try different way to skin this cat!
|
|
|
|
|
1. It is always possible to make do with a single return. I'm not sure what makes you think otherwise.
2. searching an array for a matching value is a trivial operation - why did you implement it recursively? What is so difficult in your search algorithm that it prevents you from implementing it in a simple loop?
3. having a static counter for depth of recursion is a common method, and it helps catching endless recursions. But, generally speaking, static variables can cause many issues - if there is even a remote chance you're going to use multithreading sometime in the future, just forget about it! Either way, a safer method is to create a context and pass a reference (i. e. pointer in C/C++) to the recursive function. That context object may contain a counter or any other mechanism to control recursion depth, but it won't be static: it lives in the context of the thread that initialiy called the recursive function, and it won't cause conflicts when that function is called from different clients at the same time.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Thanks Stefan,
I will take another look at the process to see if I can do it using loop(s).
|
|
|
|
|
And if your array is sorted, your search can go from O(N) to O(log N).
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Have a look at this: "Recursive Functions"[^].
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Does anybody have an idea about how to separate or detect overlapped objects? I am currently working on a project aiming at the detection crops in the late stage of growth. I did the first step, which is the segmentation (segment the plants from the background), but I got stack with detection stage because of overlapping between two crops or more (cauliflower). By the way, I am working on Opencv and visual C++. I will be grateful for your help.
modified 22-Oct-14 12:21pm.
|
|
|
|
|
HAMUDA78 wrote: Does anybody have an idea about how to separate or detect overlapped objects?
I actually, I am currently working on a project aiming at the detection crops in the late stage of growth. I did the first step, which the segmentation (segment the plants from the background), but I got stuck with detection stage because of the overlapping between the two crops or more (cauliflower). How is this a C/C++/MFC question?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Sorry, there is no DetectOccludedCauliflower() function in either Opencv or Visual C++.
If that is not your question, and you're instead asking for an algorithm to implement such a function, then maybe you should move this question to the algorithms subforum[^]
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
|
Hi,
I wanted to get all applications in the task manager with the names as displayed in that.
For eg. If i opened a movie from quicktime, i wanted to know the name of the file which is opened.
pls guide.
Thanks
|
|
|
|
|
Maybe this [^] will help.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Hello Friends
I was using DirectshowBaseclasses samples from Windows7.1 sdk with VS2010. But After upsating on Windows8.1 with Vs2013, I am not able to find samples in Windows8.1 sdk to use directshow base classes. Basically, I am looking for CBaseVideoRenderer.
If these classes are changes to some other location, please let me know if anybody using it.
Any Help will be Appreciated.
Thanks & Regards
Yogesh Sikri
|
|
|
|
|
Hello, DirectShow on Widows 8 and up are deprecated, you can continue to use source from SDK 7.1,
but pay attention, for example, DirectX are not hardware accelerated, for new project you must use
use Microsoft Windows Media Foundation new from win7
Ciao
Carlo
|
|
|
|
|
Hi,
Everytime I use ShellExecute to open a web page I lose the focus from the parent program (caller if the ShellExecute). Is there any way to open the page silently in the background or to regain focus back to the caller ?
Regards,
sdancer75
|
|
|
|
|
Try this: BringWindowToTop[^]
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
No, it didn't worked. Googleing on the net, I think that the problem is more complicated than just calling one Win32 API function.
Regards,
sdancer75
|
|
|
|
|
How are you calling ShellExecute() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi,
I am calling ShellExecute like that :
ShellExecute(NULL, "open", strURL ,NULL,NULL,SW_SHOWMINNOACTIVE);
Where strURL is the URL address to open.
Regards,
sdancer75
|
|
|
|
|
Have you tried other values for nShowCmd ?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi,
Thank you for your reply.
Yes I have already tried
SW_SHOWNOACTIVATE ,
SW_SHOWNORMAL ,
SW_SHOWMINIMIZED ,
SW_SHOWMINNOACTIVE and
SW_SHOWNOACTIVATE without any success.
Regards
sdancer75
|
|
|
|
|
Hi,
I found out accidentally, that using the SetWindowPos to the MainFrm window inside the OnCreateClient it solves the problem. It seems that setting the attribute that does not change the Z-Order of the main window keeps it always in the top.
SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
What do you think ?
Regards,
sdancer75
|
|
|
|
|
Hello,
Quick prerequisite: I'm graphic designer and I have no idea about programing.
Long story short I want to modify some graphic files but they are encrypted. I already have the code in C for decrypting them but I have no idea how to make it into working program. Also I have no idea about C language syntax so I'm not sure if I need to modify this code so I can show the program files I need to decrypt. I would be very grateful if someone could help me with this.
#include <stdio.h>
int main (int argc, char **argv)
{
FILE *inp, *outp;
int i;
char sig[] = "CF10", *ptr;
if (argc != 3)
{
printf ("usage: decode [input] [output]\n");
return -1;
}
inp = fopen (argv[1], "rb");
if (inp == NULL)
{
printf ("bad input file '%s'\n", argv[1]);
return -2;
}
ptr = sig;
while (*ptr)
{
i = fgetc (inp);
if (*ptr != i)
{
printf ("input file sig is not 'CF10'\n");
return -2;
}
ptr++;
}
outp = fopen (argv[2], "wb");
if (outp == NULL)
{
printf ("bad output file '%s'\n", argv[1]);
return -2;
}
do
{
i = fgetc(inp);
if (i != EOF)
fputc (i ^ 0x8d, outp);
} while (i != EOF);
fclose (inp);
fclose (outp);
printf ("all done. bye bye\n");
return 0;
}
modified 22-Oct-14 11:46am.
|
|
|
|
|
What development environment will you be using? Visual Studio?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
To be honest I have no preferences and I can be flexible. I doubt I'll use C again in my life. I have acces to Visual Studio but isn't it only for Visual C++, C$ and VB?
|
|
|
|