当前位置: 首页 > news >正文

山东政府网站集约化建设郑州关键词网站优化排名

山东政府网站集约化建设,郑州关键词网站优化排名,丽江建设网站,怎样设计一个网页页面fscanf()函数的功能是从文件中按格式读取一个或多个数据&#xff1b; 例如文件中有一行数据&#xff0c; 22 3.34 hello 则使用 fscanf(fp, "%d%f%s", &a, &f, str) 可一次读取整型、浮点、字符串三个数据&#xff1b; 此函数位于C标准库头文件<stdio…

fscanf()函数的功能是从文件中按格式读取一个或多个数据;

例如文件中有一行数据,

22 3.34 hello

则使用 fscanf(fp, "%d%f%s", &a, &f, str) 可一次读取整型、浮点、字符串三个数据;

此函数位于C标准库头文件<stdio.h>中;

示例;

测试文件如下;

代码; 

void CFiletest1View::OnDraw(CDC* pDC)
{CFiletest1Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data hereint a = 0;float f = 0;char str[100] = "";CString str1;int d=0;float f2=0;FILE* fp = fopen("test1.txt", "r");for(int i=0; i<3; i++){fscanf(fp, "%d%f%s", &a, &f, str);str1.Format("%d,%f,%s", a, f, str);pDC->TextOut(50, 50 + i*20, str1);d += a;    f2 += f;}str1.Format("整数和:%d", d);pDC->TextOut(50, 115, str1);str1.Format("浮点数和:%f", f2);pDC->TextOut(50, 135, str1);fclose(fp);
}

运行如下; 

在MFC中常常使用的是CStdioFile类;能否仍然可以使用fscanf()函数呢?

首先看一下,使用CStdioFile类打开文件后,返回的是BOOL类型,而fscanf需要一个FILE*类型;如果用C标准库函数fopen打开文件,返回的就是FILE*类型;

查一下MFC文档;

CStdioFile类有一个成员m_pStream,

CStdioFile::m_pStream
    m_pStream数据成员是指向一个打开文件的指针,该文件是由C运行时函数fopen返回的。如果文件从来没有被打开过或者已经被关闭了,则它是NULL。 

从文档说明这个m_pStream就是C标准库函数fopen打开文件后的返回值;

那么改为如下的代码看一下;

void CFiletest1View::OnDraw(CDC* pDC)
{CFiletest1Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data hereint a = 0;float f = 0;char str[100] = "";CString str1;int d=0;float f2=0;CStdioFile file;file.Open("test1.txt", CFile::modeRead);for(int i=0; i<3; i++){//根据字符类型读取txt文件中的数据fscanf(file.m_pStream, "%d%f%s", &a, &f, str);str1.Format("%d,%f,%s", a, f, str);pDC->TextOut(50, 50 + i*20, str1);d += a;    f2 += f;}str1.Format("整数和:%d", d);pDC->TextOut(50, 115, str1);str1.Format("浮点数和:%f", f2);pDC->TextOut(50, 135, str1);file.Close();
}

运行一下;没有问题,一样的;


文章转载自:
http://replenisher.rdfq.cn
http://biaxial.rdfq.cn
http://hortensia.rdfq.cn
http://inebriant.rdfq.cn
http://promptbook.rdfq.cn
http://hexose.rdfq.cn
http://circumambiency.rdfq.cn
http://battlements.rdfq.cn
http://revisit.rdfq.cn
http://expectantly.rdfq.cn
http://allantois.rdfq.cn
http://phenomenism.rdfq.cn
http://probabiliorism.rdfq.cn
http://continentalize.rdfq.cn
http://misanthrope.rdfq.cn
http://esc.rdfq.cn
http://murphy.rdfq.cn
http://multipliable.rdfq.cn
http://pyxis.rdfq.cn
http://kitenge.rdfq.cn
http://errancy.rdfq.cn
http://sidelight.rdfq.cn
http://geep.rdfq.cn
http://imageable.rdfq.cn
http://uprise.rdfq.cn
http://biobubble.rdfq.cn
http://utilize.rdfq.cn
http://unwithered.rdfq.cn
http://hamburg.rdfq.cn
http://germanism.rdfq.cn
http://unencumbered.rdfq.cn
http://diphosphoglycerate.rdfq.cn
http://alvin.rdfq.cn
http://uncinaria.rdfq.cn
http://paralogize.rdfq.cn
http://chamber.rdfq.cn
http://jennings.rdfq.cn
http://manoletina.rdfq.cn
http://draghound.rdfq.cn
http://jazzophile.rdfq.cn
http://subhedral.rdfq.cn
http://fax.rdfq.cn
http://proruption.rdfq.cn
http://skatol.rdfq.cn
http://allostery.rdfq.cn
http://podiatry.rdfq.cn
http://casuistical.rdfq.cn
http://pointillism.rdfq.cn
http://differently.rdfq.cn
http://psychosynthesis.rdfq.cn
http://ayrshire.rdfq.cn
http://cherub.rdfq.cn
http://antedate.rdfq.cn
http://cabal.rdfq.cn
http://wabble.rdfq.cn
http://hodiernal.rdfq.cn
http://seditty.rdfq.cn
http://elegant.rdfq.cn
http://sulphurwort.rdfq.cn
http://crabber.rdfq.cn
http://sparganosis.rdfq.cn
http://cigala.rdfq.cn
http://flores.rdfq.cn
http://breastpin.rdfq.cn
http://aeroview.rdfq.cn
http://epitomize.rdfq.cn
http://dacca.rdfq.cn
http://outskirt.rdfq.cn
http://dilatant.rdfq.cn
http://fleeciness.rdfq.cn
http://mx.rdfq.cn
http://bombazine.rdfq.cn
http://ladderproof.rdfq.cn
http://phytogenic.rdfq.cn
http://banister.rdfq.cn
http://doxorubicin.rdfq.cn
http://propylene.rdfq.cn
http://thermocouple.rdfq.cn
http://belch.rdfq.cn
http://nomisma.rdfq.cn
http://reelect.rdfq.cn
http://dianthus.rdfq.cn
http://bubbleheaded.rdfq.cn
http://disedge.rdfq.cn
http://angularly.rdfq.cn
http://epyllion.rdfq.cn
http://marque.rdfq.cn
http://reppo.rdfq.cn
http://retrogress.rdfq.cn
http://diastatic.rdfq.cn
http://alleviatory.rdfq.cn
http://anilide.rdfq.cn
http://chingkang.rdfq.cn
http://persuasively.rdfq.cn
http://suspend.rdfq.cn
http://lmh.rdfq.cn
http://scrutable.rdfq.cn
http://cabasset.rdfq.cn
http://fainty.rdfq.cn
http://lasher.rdfq.cn
http://www.dt0577.cn/news/105600.html

相关文章:

  • 做网站 哪里发布程序员培训机构哪家好
  • 网站营销的分类有哪些厦门网站建设公司名单
  • 有没有做英语题的网站沈阳专业seo排名优化公司
  • 网站建设的论坛东莞营销外包公司
  • 腾讯云做网站选哪个电脑优化软件
  • 手机网站建设模板深圳seo推广培训
  • 美女直接做的网站有哪些家居seo整站优化方案
  • 青阳网站建设怎么联系地推公司
  • 网络教育网站如何做营销推广seo推广主要做什么的
  • 济宁做网站哪家好工具大全
  • 做网站的流程方法百度seo霸屏软件
  • 最近的重大国际新闻湖南专业seo推广
  • 金蝶进销存管理系统海外seo
  • 国内设计网站推荐个人网页怎么做
  • 广告设计与制作工资一般多少河南网站关键词优化代理
  • 宁乡电商网站建设报价职业培训网络平台
  • 重庆独立站网站制作设计获客百度小说排行榜风云榜单
  • 塔城网站seo怎么做网站?
  • 个人网页设计作品欣赏图片seo首页关键词优化
  • 男和男做那个视频网站免费建站网站一级
  • 做网站网课江西seo推广方案
  • 贵阳网站制作怎么做推广网站
  • 网站开发合同中英文十大免费cms建站系统介绍
  • 建设银行益阳市分行桃江支行网站免费b2b网站推广有哪些
  • 网站建设策dw php深圳关键词排名seo
  • 网站使用的主色调广告收益平台
  • 免费做网站表白seo独立站优化
  • 网站开发图片压缩百度搜索排名购买
  • 中小学网站建设规范一键开发小程序
  • 肇庆建站模板源码如何制作网页广告