码迷,mamicode.com
首页 > 其他好文 > 详细

fscanf功能具体解释

时间:2015-06-07 10:52:18      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

cfscanf技术分享 fscanf

fscanf

: 格,fscanf格格

:int fscanf(FILE *stream, char *format,[argument...]);

int fscanf(格);

for example:

FILE*fp;

chara[10];

intb;

doublec;

fscanf(fp,"%s%d%lf",a,&b,&c)

值值[argument...]

format格格

datatxt格

2,50,41,w,20.585828

4,52,51,r,52.012547

.........................

 似

.......................


值值

#include<stdio.h>
#include<stdlib.h>


int main()
{
  int fd;
  long dev;
  long offset;
  long length;
  char ch;
  double ts=0.000000;
  if((fd=fopen("/home/haixian/ceshi/data.txt","r"))<0)
   {
     printf("open the file is error!\n");
     exit(0);
   }
  lseek(fd,0,SEEK_SET);
  
  
  while(5==fscanf(fd,"%ld,%ld,%ld,%c,%lf\n",&dev,&offset,&length,&ch,&ts))
  {格easy值
     printf("%ld,%ld,%ld,%c,%lf\n",dev,offset,length,ch,ts);
  }
close(fd);
return 0;
}

fscanf


fscanf功能具体解释

标签:

原文地址:http://www.cnblogs.com/mengfanrong/p/4557716.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!