linux下常用函数(2) ntohs fprintf strupr strlwr

1,ntohs() 将一个无符号短整形数从网络字节顺序转换为主机字节顺序。

    printf("%ld
",(eitP.tcp->th_dport));  25834(网络)
    printf("%ld
",ntohs(eitP.tcp->th_dport)); 60004

2, int fprintf(FILE *stream, const char *format, ...) 发送格式化输出到流 stream 中。

int main(){
fprintf(stdout,"Hello ");
fprintf(stderr,"World!");
return0;
}
这段代码的输出是World!Hello
在默认情况下,stdout是行缓冲的,他的输出会放在一个buffer里面,只有到换行的时候,才会输出到屏幕。而stderr是无缓冲的,会直接输出,举例来说就是printf(stdout, "xxxx") 和 
printf(stdout, "xxxx "),前者会憋住,直到遇到新行才会一起输出。而printf(stderr, "xxxxx"),不管有么有 ,都输出。

3,strupr(char *s)函数用来将指向的字符串全部转换为大写的形式

4,strlwr(char *s)函数则用来将指向的字符串全部转换为小写的形式

原文地址:https://www.cnblogs.com/kony9527/p/10708340.html