Skip to content

Instantly share code, notes, and snippets.

@treeherder
Last active August 29, 2015 13:56
Show Gist options
  • Save treeherder/9337667 to your computer and use it in GitHub Desktop.
Save treeherder/9337667 to your computer and use it in GitHub Desktop.
trouble with dereferecing
#include <stdio.h>
struct ret
{
int c_1;
int c_2;
};
int main()
{
struct ret retu = {.c_1 = 32, .c_2 = 16};
printf("%d %d\n", retu.c_1, retu.c_2);
}
#include <stdio.h>
struct ret
{
int c_1;
int c_2;
};
int main()
{
struct ret ret_val;
struct ret *retu;
retu = &ret_val;
retu->c_1 = 32;
retu->c_2 = 16;
printf("%d %d\n", retu->c_1, retu->c_2);
}
#include <stdio.h>
struct val
{
int c_1;
int c_2;};
struct val ret_val (int c_1, int c_2) {
struct val ret_struct;
ret_struct.c_1 = c_1;
ret_struct.c_2 = c_2;
return ret_struct;
}
int main()
{
struct val ret;
ret = ret_val(23,46);
printf("%d %d\n", ret.c_1, ret.c_2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment