C/C++基础
Ken0608
这个作者很懒,什么都没留下…
展开
-
C语言的get函数汇总
1、int getc(FILE *stream); 从指定输入流 stream 的当前位置读取一个字符,若读到文件尾而无数据时便返回EOF。main(){ int c; FILE *fp= fopen("d:\\a.txt","r"); fpos_t p=4; fsetpos(fp,&p); c=getc(fp); putchar(c);}文件内容转载 2013-10-11 08:58:31 · 1821 阅读 · 0 评论 -
C语言的put函数汇总
1、int putc(int ch, FILE *stream); 输出一字符到指定流中int main(void){ char msg[] = "Hello world\n"; int i = 0; while (msg[i]) putc(msg[i++], stdout); return 0;}2、int putchar(int ch);转载 2013-10-11 08:59:56 · 7734 阅读 · 0 评论 -
如何设置socket的Connect超时
1.首先将标志位设为Non-blocking模式,准备在非阻塞模式下调用connect函数2.调用connect,正常情况下,因为TCP三次握手需要一些时间;而非阻塞调用只要不能立即完成就会返回错误,所以这里会返回EINPROGRESS,表示在建立连接但还没有完成。3.在读套接口描述符集(fd_set rset)和写套接口描述符集(fd_set wset)中将当前套接口置位(用FD_转载 2013-10-17 15:20:28 · 2485 阅读 · 0 评论