Quote:FILE *got_file(char *str)
FILE *fp = fopen(str, "r");
will this be OK? the fp is a pointer points to FILE struct which stores in stack, I think. Any problems here?
This is OK. The
struct is NOT (a temporary) on the stack, its pointer is (but the pointer value, that is the address is copied as return value).
static char *test = "a test";
Yes, it is OK, static variables are not temporaries.
Quote:static char *got_str2（）
char *test = "a test";
will this OK?
Ugly as it stands (I won't use it, if you ask me), it should
be OK too. Because string literals are not temporaries.