【发布时间】:2017-06-11 02:11:14
【问题描述】:
MAIN.C 触发函数b()
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <mysql.h>
#include "main.h"
int main() {
const char *a;
a = b();
printf("%s\n", a);
}
MAIN.H 中的函数 b() 以结果响应
static inline const char *b(){
const char* retu;
char query[300];
sprintf(query, "select * from TEST limit 1");
retu = query;
return retu;
}
这是 MAIN.C 脚本打印的内容:
v����
这是奇怪的东西。不像预期的那样。 (有意)
【问题讨论】:
-
未定义的行为是未定义的。您很幸运,它没有起作用,请参阅副本。
标签: c