C语言几个有意思的问题
2013-12-12 11:44
225 查看
1、gets和fgets的区别
char *gets(char *s);
gets() reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF, which it replaces with '\0'.
No check for buffer overrun is performed (see BUGS below).
char *fgets(char *s, int size, FILE *stream);
fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A '\0' is stored after the last character
in the buffer.
2、运行时改变程序名称
memset(argv[0],0,strlen(argv[0])); strncpy(argv[0],"NewName",7);然后ps可以发现程序名称改变了
3、print从右到左运算输出
#include <stdio.h>
int main(void)
{
int a = 10, b = 20, c = 30;
printf( "\n %d..%d..%d\n", a+b+c,(b=b*2),(c=c*3) );
}
140..40..90
char *gets(char *s);
gets() reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF, which it replaces with '\0'.
No check for buffer overrun is performed (see BUGS below).
char *fgets(char *s, int size, FILE *stream);
fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A '\0' is stored after the last character
in the buffer.
2、运行时改变程序名称
memset(argv[0],0,strlen(argv[0])); strncpy(argv[0],"NewName",7);然后ps可以发现程序名称改变了
3、print从右到左运算输出
#include <stdio.h>
int main(void)
{
int a = 10, b = 20, c = 30;
printf( "\n %d..%d..%d\n", a+b+c,(b=b*2),(c=c*3) );
}
140..40..90
相关文章推荐
- C语言编程容易混淆的几个问题总结
- C语言的几个有趣问题
- C语言测试:想成为嵌入式程序员应知道的几个基本问题
- 关于C语言几个关键字问题的总结
- 绝对能够测试你的C语言功力的几个问题!
- 绝对能够测试你的C语言功力的几个问题!
- [原创]绝对能够测试你的C语言功力的几个问题 - 参考答案
- C语言中解决变参问题的几个宏
- 碰见C语言的几个小问题
- C语言编写字符串拷贝函数应注意的几个问题
- 关于单链表的几个有意思的问题
- 关于String的几个有意思的小问题
- 绝对能够测试你的C语言功力的几个问题 - 参考答案
- 绝对能够测试你的C语言功力的几个问题! (ZZ)
- 绝对能够测试你的C语言功力的几个问题!
- 绝对能够测试你的C语言功力的几个问题及其讲解分析
- C语言学习第一课,新手比较疑惑的几个问题
- 关于C语言求几个分数之和的问题
- C语言中关于scanf()易错的几个问题
- 绝对能够测试你的C语言功力的几个问题!