Return from a function

M

Michael Bell

I am a newbie, and looking through some code which I have been given
as an example of "how to do things right", I see functions like this:-

void FunctionName(void)

but in the function itself, after the "workings" I find :-

return StructName;
}


This seems very strange. It is declared as having no return type, but
yet it is written to return quite a big thing, and plainly the program
won't work unless it does return it. What's the explanation?

Michael Bell

--
 
V

Victor Bazarov

Michael said:
I am a newbie, and looking through some code which I have been given
as an example of "how to do things right", I see functions like this:-

void FunctionName(void)

but in the function itself, after the "workings" I find :-

return StructName;
}


This seems very strange. It is declared as having no return type, but
yet it is written to return quite a big thing, and plainly the program
won't work unless it does return it. What's the explanation?

Somebody must have screwed up. Does it compile at all? AFAICT, it
shouldn't. But then again, you didn't post the complete code...

V
 
D

Default User

Michael said:
I am a newbie, and looking through some code which I have been given
as an example of "how to do things right", I see functions like this:-

void FunctionName(void)

but in the function itself, after the "workings" I find :-

return StructName;
}


This seems very strange. It is declared as having no return type, but
yet it is written to return quite a big thing, and plainly the
program won't work unless it does return it. What's the explanation?

Cut and paste the entire piece of code in question, not your
interpretation. Then we can see what we really have.




Brian
 
D

Default User

Juha said:
Wouldn't that destroy the original? Sounds like a bad idea.

Har.

I'm old enough to remember the days when the phrase meant exactly that,
you cut out the text with scissors or and Exact-o and pasted it into
your document.




Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top