Advertisement
GegoXaren

test2991.c

May 4th, 2022
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. typedef struct Foo_t {
  4.   int a;
  5.   char * s;
  6. } Foo;
  7.  
  8. void my_func (Foo  foo) {
  9.   fprintf (stdout, "a: %i, s: %s\n", foo.a, foo.s);
  10. }
  11.  
  12. void my_func2 (Foo * foo) {
  13.   fprintf (stdout, "a: %i, s: %s\n", foo->a, foo->s);
  14. }
  15.  
  16. int main (char * argv, size_t argc) {
  17.   // This does work
  18.   my_func ((Foo) {10, "World!"});
  19.  
  20.   // This does not work.
  21.   my_func2 ((Foo *) {5, "Hello!"});
  22.   return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement