I read about return values โโbetween function calls,
and experimented with the following code snippet:
#include <stdio.h> #define MSIZE 10 struct simple { char c_str[MSIZE]; }; struct simple xprint(void) { struct simple ret = { "Morning !" }; return ret; } int main(void) { printf("Good %s\n", xprint().c_str); return 0; }
The code compiles without errors and warnings.
Tested with GCC 4.4.3 compilers (Ubuntu 4.4.3-4ubuntu5.1) and Visual C ++.
gcc -m32 -std=c99 -Wall -o test structaddr.c cl -W3 -Zi -GS -TC -Fetest structaddr.c
Exit:
Good morning!
I am a little confused by the result.
Is the code written correctly?
My question is:
source share