C语言中fprintf_c语言gets函数用法

C语言中fprintf_c语言gets函数用法c语言中fprintf函数C中的fprintf()函数(fprintf()functioninC)Prototype:原型:intfprintf(FILE*filename,constchar*string,….);Parameters:参数:FILE*filename,constchar*stringetc….

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

c语言中fprintf函数

C中的fprintf()函数 (fprintf() function in C)

Prototype:

原型:

    int fprintf(FILE *filename, const char *string, . . . .);

Parameters:

参数:

    FILE *filename, const char *string etc.

Return type: int

返回类型: int

Use of function:

使用功能:

Like printf() function, fprintf() function is used to write the argument statement string on the file stream. Through the fprintf() function we write or store the values with the string. The prototype of the function fprintf() is: int fprintf(FILE *filename, const char *string, . . . .);

与printf()函数类似, fprintf()函数用于在文件流上写入参数声明字符串。 通过fprintf()函数,我们可以将值写入或存储在字符串中。 函数fprintf()的原型是: int fprintf(FILE * filename,const char * string,。。。);

Here string is the user defined string along with the existing data types (likes int, float, char etc).

这里的string是用户定义的字符串以及现有的数据类型(例如int,float,char等)。

C中的fprintf()示例 (fprintf() example in C)

#include<stdio.h>
#include<stdlib.h>
int main()
{
   
   
	//Initialize the file pointer
	FILE *f;
	char ch[100];
	
	// open the file for read and write operation
	if((f=fopen("includehelp.txt","r+"))==NULL){
   
   
		//if the file does not exist print the string
		printf("Cannot open the file...");
		exit(1);
	}
	
	for(int i=0;i<10;i++){
   
   
		//enter the strings with values in the file
		fprintf(f,"The count number is %d\n",i+1);	
	}
	fclose(f);
	
	// open the file for read and write operation
	if((f=fopen("includehelp.txt","r+"))==NULL){
   
   
		//if the file does not exist print the string
		printf("Cannot open the file...");
		exit(1);
	}

	printf("File content is--\n");
	printf("\n...............print the strings..............\n\n");
	while(!feof(f)){
   
   
		//takes the first 100 character in the character array 
		fgets(ch,100,f);
		//and print the strings
		printf("%s",ch);
	}
	//close the file
	fclose(f);
	
	return 0;
}

Output

输出量

fprintf example in c

翻译自: https://www.includehelp.com/c-programs/fprintf-function-in-c-language-with-example.aspx

c语言中fprintf函数

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/180603.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 谷歌dns和阿里dns_最快dns排行

    谷歌dns和阿里dns_最快dns排行国内比较大型大众常用的公共DNS服务器公共DNS服务器,即系统默认的DNS解析服务器。DNS全称DomainNameSystem,即域名解析系统。DNS帮助用户在互联网上寻找路径。在互联网上的每一个计算机都拥有一个唯一的地址,称作“IP地址”(即互联网协议地址)。由于IP地址(为一串数字)不方便记忆,DNS允许用户使用一串常见的字母(即“域名”)取代。公共DNS服务器,具有无广告、可以在一定程度上防止DNS劫持、不需因上网环境的改变而改变等优势,但是,使用公共DNS也可能存在系统响应慢、被劫

    2022年9月6日
    3
  • redis HSCAN命令及jedis的hscan方法[通俗易懂]

    redis HSCAN命令及jedis的hscan方法[通俗易懂]参考文档:http://doc.redisfans.com/key/scan.html@Override publicScanResultshscanToResltByVague(Stringkey,Stringpattern,Stringcursor,intpageSize){ List<Map.Entry<String,String>>result=null; List<Map.Entry<String,String&

    2022年10月31日
    0
  • python 二叉树中序遍历[通俗易懂]

    python 二叉树中序遍历[通俗易懂]根据树的递归性,使用List存储下面这棵树,然后编写函数对其进行中序遍历,最后删除节点D。递归实现中序遍历列表存储的二叉树python列表模拟二叉树存放,列表=[[左子树],根节点,[右子树]]列表里有列表,列表里又有列表。之前用treelist[1]==[]判断return,会有超限的问题。后来想了想,用列表长度判断是否return似乎是个不错的选择。d…

    2022年9月13日
    0
  • Dataset之CIFAR-10:CIFAR-10数据集的简介、下载、使用方法之详细攻略

    Dataset之CIFAR-10:CIFAR-10数据集的简介、下载、使用方法之详细攻略Dataset之CIFAR-10:CIFAR-10数据集的简介、下载、使用方法之详细攻略目录CIFAR-10的简介1、与MNIST数据集中目比,CIFAR-10真高以下不同点2、TensorFlow官方示例的CIFAR-10代码文件3、CIFAR-10数据集的数据文件名及用途4、基于CIFAR-10数据集最新算法预测准确率对比CIFAR-10的下载1、下载CIFAR-10数据集的全部数据CIFAR-10使用方法1、使用TF读取CIFAR-10数据官网链接:TheCIFAR-10datas

    2022年10月17日
    0
  • mit6.033_mit6.830

    mit6.033_mit6.8301. CPU设计权衡2. 处理器性能3. 提示:Beta指令集4. 方法:提升特性5. 多端口寄存器文件6. 寄存器文件时序7. ALU指令8. 指令获取/解码9. ALUOP数据路径110. ALUOP数据路径211. ALU操作(带有常量)112. ALU操作(带有常量)213. load指令114. load指令215. store指令116. store指令217. JMP指令118. JMP指令219. BEQ/BNE

    2022年9月13日
    0
  • HibernateTemplate的使用[通俗易懂]

    HibernateTemplate的使用[通俗易懂]HibernateTemplate提供了非常多的常用方法来完成基本的操作,比如增加、删除、修改及查询等操作,Spring2.0更增加对命名SQL查询的支持,也增加对分页的支持。大部分情况下,使用Hibernate的常规用法,就可完成大多数DAO对象的CRUD操作。  下面是HibernateTemplate的常用方法。  delete(Objecten

    2022年6月29日
    28

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号