Skip to content

Instantly share code, notes, and snippets.

@mlieberman85
Created August 12, 2013 15:21
Show Gist options
  • Save mlieberman85/6211806 to your computer and use it in GitHub Desktop.
Save mlieberman85/6211806 to your computer and use it in GitHub Desktop.
Returning a struct from a function.
#include<stdio.h>
typedef struct
{
int x;
int y;
} myStruct;
myStruct myFun(myStruct a)
{
a.x = 5;
a.y = 6;
return a;
}
int main()
{
myStruct b = {5, 3};
myStruct x = myFun(b);
printf("%i %i", x.x, x.y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment