C语言问题集

征服C指针:P70
#include "stdio.h" char *int_to_str(int int_value){ static char buf[20]; sprintf(buf,"%d",int_value); return buf; } int main(){ char *str1,*str2; str1=int_to_str(5); str2=int_to_str(10); printf("str1..%s ,str2..%s ",str1,str2); printf("str1..%s ,str2..%s ",int_to_str(5),int_to_str(10)); return 0; }

 输出结果是

1 str1..10  ,str2..10
2 str1..5  ,str2..5
原文地址:https://www.cnblogs.com/cc-jony/p/3752850.html