![]() |
| | #1 |
| Registered User Join Date: Feb 2009 Location: Seattle
Posts: 39
| How to write a function which returns a structure |
| MSF1981 is offline | |
| | #2 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| Same as any other kind of function which returns a value. There's no new syntax, so try the obvious thing and see what happens. Unless you're using some 30-year old fossil compiler, this capability has been officially part of C since 1989.
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #3 |
| Registered User Join Date: Jan 2009
Posts: 26
| Code: typedef struct
{
int a;
} STR;
STR Func()
{
STR str;
str.a = 5;
return(str);
}
|
| baccardi is offline | |
![]() |
| Tags |
| function, return, struct, structure |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Polynomials and ADT's | Emeighty | C++ Programming | 20 | 08-19-2008 08:32 AM |
| Screwy Linker Error - VC2005 | Tonto | C++ Programming | 5 | 06-19-2007 02:39 PM |
| Game Pointer Trouble? | Drahcir | C Programming | 8 | 02-04-2006 02:53 AM |
| Binary Search Trees Part III | Prelude | A Brief History of Cprogramming.com | 16 | 10-02-2004 03:00 PM |
| qt help | Unregistered | Linux Programming | 1 | 04-20-2002 09:51 AM |