`

C语言几个有意思的问题

 
阅读更多

1、gets和fgets的区别

char *gets(char *s);

gets() reads a line from stdin into the buffer pointed to by s untileither a terminating newline or EOF, which it replaces with '\0'. Nocheck 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


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics