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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 英特尔处理器性能排行2021_intel芯片组天梯图

    英特尔处理器性能排行2021_intel芯片组天梯图用于企业服务站和工作站的电脑硬件要求会比较高,常用的处理器可能会用到英特尔至强xeonCPU处理器。而至强xeon系列的型号有很多,不同的型号的性能也有差异,那么至强cpu哪些比较好呢?下面小编就给大家分享下英特尔2021至强cpu性能排行天梯图,供大家参考。2021至强cpu性能排行天梯图前100名情况如下:(图片来源于网络)以上便是英特尔2021至强cpu性能排行天梯图前100名cpu的情况,大家可以根据自己的需求选择合适的cpu处理器即可。更多有用的系统知识和重.

    2022年9月20日
    1
  • PHP实现密码生成器包含大小写字母数字特殊字符

    PHP实现密码生成器包含大小写字母数字特殊字符

    2022年2月18日
    48
  • awstats 安装

    awstats 安装来自http://www.cnblogs.com/fnng/archive/2012/08/31/2666175.htmlAwstats是一个非常简洁而且强大的统计工具。它可以统计您站点的如下信息:一:访问量,访问次数,页面浏览量,点击数,数据流量等精确到每月、每日、每小时的数据二:访问者国家、访问者IP、操作系统、浏览器等三:Robots/Spiders的统计四:…

    2022年7月16日
    13
  • 惠普电脑一直刷新_我的电脑设备管理器在哪

    惠普电脑一直刷新_我的电脑设备管理器在哪公司的Hp电脑,设备管理一直刷新,鼠标时断时续,很搞心态,得有一个月了,一直找不到原因,后来禁用了设备管理的生物识别设备就可以了,反正也用不到指纹.

    2022年8月12日
    3
  • SQL SERVER拼接字符串(字符串中有变量)

    SQL SERVER拼接字符串(字符串中有变量)一、拼接字符串(整个字符串不分割)步骤:  1、首先在字符串的前后加单引号;  2、字符串中的变量以’’’+@para+’’’在字符串中表示;  3、若在执行时存在类型转换错误,则应用相应的类型转换函数,对变量进行类型转换(如cast()函数)。示例一:包含SQL拼接字符串的存储过程:CreateProcedureTest@TestIDintAsDeclare@sn…

    2022年6月17日
    393
  • 计算机学科的发展方向

    计算机学科的发展方向计算机专业毕业后大致的工作方向是软、硬、网、图四大类尤其以软件、网络为现今的首选从岗位上分,又可以分为技术道路、营销道路两大方向if你选择作技术,then从现在开始,牢记:天道酬勤!!!if你选择软件技术then每天都要用大量的时间学习高级语言,绝对不能仅限于学校的安排。优秀的程序员都是大学阶段就已经自学得非常深入了。ifyou选择网络技术,那么

    2022年5月10日
    45

发表回复

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

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