Last active
August 29, 2015 13:56
-
-
Save treeherder/9337667 to your computer and use it in GitHub Desktop.
trouble with dereferecing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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