
IO
标准IO:fopen fread fwrite,主要是常规的非系统文件读写数据 文件IO:open read write linux系统当做文件读写数据
静思心远
嵌入式&&人工智能
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
三种不同IO访问方式
三种不同IO访问方式三种不同IO访问方式1.基本帧IO访问方式2.内存映射缓冲区(V4L2_MEMORY_MMAP)3.用户空间缓冲区(V4L2_MEMORY_USERPTR)三种不同IO访问方式三种不同IO访问方式(内核中还支持了其它的访问方式,暂不讨论):1.基本帧IO访问方式read和write:是基本帧IO访问方式,通过read读取每一帧数据,数据需要在内核和用户之间拷贝,这种方式访问速度可能会非常慢;2.内存映射缓冲区(V4L2_MEMORY_MMAP)内存映射缓冲区(V4L2_MEM原创 2021-09-22 10:33:16 · 2221 阅读 · 0 评论 -
c读取一行字符串,以及c++读取一行字符串
一 c读取一行字符串1 gets#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int size = 1024; char* buff = (char*)malloc(size); // read lines while(NULL != gets(buff)){ printf("转载 2020-10-09 14:53:38 · 5293 阅读 · 0 评论 -
2.1文件IO:open
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>int main(int argc,char *argv[]){ int fd; /* *int open(const c.原创 2020-08-23 15:30:34 · 193 阅读 · 0 评论 -
1.2标准IO:fread fwrite
#include <stdio.h>#include <string.h>#include <errno.h>struct student{ char name[15]; int id; int age;};//./a.out filenameint main(int argc, const char *argv[]){ FILE *fp; //将stu1写入文件 //从文件中读取信息存放到stu2 struct student stu.原创 2020-08-17 22:47:34 · 253 阅读 · 0 评论 -
1.1标准IO:fopen
#include <stdio.h>#include <errno.h>#include <string.h>//./a.out filenameint main(int argc, const char *argv[]){ FILE *fp; if(argc < 2) { fprintf(stderr,"Usage : %s filename.\n",argv[0]); return -1; } /*FILE * fopen(c.原创 2020-08-17 22:47:14 · 322 阅读 · 0 评论 -
2.2文件IO:read write
#include #include //control file open close#include // data types,ssize_t #include // check stat#include //call unix,for read write#include int main(int argc, const char *argv[])原创 2016-10-28 21:37:48 · 405 阅读 · 0 评论 -
标准IO:4fgetc fputc
#include <stdio.h>int main(int argc, const char *argv[]){ int ch; /* *int fputc(int c,FILE *fp); *功能:将一个c写到fp代表的文件 *返回值:成功返回写入的字符,出错都会返回EOF(-1) */ while(1) { /*ctrl + d 让fgetc读取失败,返回 -1*/ ch = fgetc(stdin); fputc(ch,stdout); }.原创 2020-08-17 22:47:51 · 230 阅读 · 0 评论 -
标准IO:3fgets
#include <stdio.h>int main(int argc, const char *argv[]){ char buf[5]; while(1) { /*char *fgets(char *s,int size,FILE *stream) *功能:从一个流中读取多个字符存放在s保存的地址 *返回值:成功返回s,失败或读到文件尾部返回NULL * * 注意: *1.每次最多只能读取size - 1个字符 *2.读取的过程中遇到.原创 2020-08-17 22:45:49 · 219 阅读 · 0 评论 -
linux动态库libxx.so
head.h#ifndef _HEAD_H#define _HEAD_Hextern int add(int a,int b);extern int sub(int a,int b);extern int mul(int a,int b);extern int div(int a,int b);#endifaddsub.cint add(int a,int b){ return a + b;}int sub(int a,int b){ return a - b原创 2020-08-23 15:28:04 · 584 阅读 · 0 评论 -
linux制作静态库 libxx.a
head.h#ifndef _HEAD_H#define _HEAD_Hextern int add(int a,int b);extern int sub(int a,int b);extern int mul(int a,int b);extern int div(int a,int b);#endifmuldiv.cint mul(int a,int b){ return a * b;}int div(int a,int b){ return a / .原创 2020-08-23 15:27:42 · 350 阅读 · 0 评论 -
my_ls
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <pwd.h>#include <grp.h>#include <time.h>.原创 2020-08-17 22:58:36 · 277 阅读 · 0 评论 -
truncate
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>//./a.out file1 file2int main(int argc, const char *argv[]){ int len; struct stat f_info; if(stat(argv[1],&f_i.原创 2020-08-17 22:58:09 · 259 阅读 · 0 评论 -
文件操作copy
#include <stdio.h>#include <string.h>#include <errno.h>int do_copy(FILE *fp_src,FILE *fp_dest){ char buf[1024]; while(fgets(buf,sizeof(buf),fp_src) != NULL ) { fputs(buf,fp_dest); } return 0;}//./a.out file1 file2int ma.原创 2020-08-17 22:48:36 · 220 阅读 · 0 评论 -
scan_Dir
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <sys/types.h>#include <dirent.h>int display_dir(const char *name){ DIR *pdir; struct dirent *pdirent; int file_count = 0,dir_.原创 2020-08-17 22:51:55 · 342 阅读 · 0 评论 -
strtok
#include <stdio.h>#include <stdlib.h>#include <string.h>int main(int argc, const char *argv[]){ char string[1024]; char *pcmd,*pfile; while(1) { printf("input>"); fgets(string,sizeof(string),stdin); /*将'\n'字符去掉即转成'\0'*.原创 2020-08-17 22:51:20 · 149 阅读 · 0 评论 -
记录Log
#include <stdio.h>#include <string.h>#include <errno.h>#include <stdlib.h>#include <time.h>#include <unistd.h>int get_line(FILE *fp){ int line = 0; char buf[1024]; //buf:....\n\0 while(fgets(buf,sizeof(buf.原创 2020-08-17 22:50:26 · 233 阅读 · 0 评论 -
stdin stderr stdout
#include <stdio.h>//./a.out xx int main(int argc, const char *argv[]){ FILE *fp; /*fprintf : assign a stream to output*/ fprintf(stderr,"STDERROR:hello word.\n"); fprintf(stdout,"STDOUT:hello word.\n"); fp = fopen(argv[1],"r"); return 0;.原创 2020-08-17 22:48:08 · 189 阅读 · 0 评论 -
fgetc
#include <stdio.h>int main(int argc, const char *argv[]){ int ch; /* *int fgetc(FILE *fp); *功能:从一个流每次读取一个字符 *返回值:成功返回读取的字符,都到文件尾部或者出错都会返回EOF(-1) * * 注意: * 返回值如果是char类型:不能IBM扩展字符[128,255] * 返回值如果是unsigned char 类型:无法区分EOF(-1),-1对于un.原创 2020-08-17 22:46:49 · 1634 阅读 · 0 评论 -
ubuntu QT开发环境(三种方法安装Qt4.8,其中apt-get方法安装QT库最简单)good
方法一 QT4.8.0库+QT Creator 2.4.1特别声明:此方法极其耗时间,看电脑性能了。配置configure可减少编译时间1.下载Qt 。进入网址http://qt.nokia.com/downloads,下Qt libraries4.8.0 for Linux/x11(228MB) 和QtCreator(65MB)。 2.解压文件。进转载 2017-08-07 15:23:09 · 1283 阅读 · 0 评论