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


相关推荐

  • 拉格朗日乘数法求得的是最值还是极值_微观经济拉格朗日方程求极值

    拉格朗日乘数法求得的是最值还是极值_微观经济拉格朗日方程求极值一、拉格朗日乘数法简介在日常的生产生活中,当我们要要安排生产生活计划的时候,常常会在现实物理资源约束的条件下,计算得到收益最大或者损失最小的计划;像这种对自变量有附加条件的极值称为条件极值;拉格朗日乘数法是一种直接计算解决条件极值的方法;拉格朗日乘数法的定义如下:设有f(x,y),φ(x,y)f(x,y),\varphi(x,y)f(x,y),φ(x,y)两个函数,并且两者都有一阶连续偏导数,则做拉格朗日函数为F(x,y,λ)=f(x,y)+λφ(x,y)F(x,y,\lambda)

    2025年5月23日
    4
  • python 之免费ip代理池[通俗易懂]

    python 之免费ip代理池[通俗易懂]基于proxy_pool,部署了一个开放的免费ip代理池,提供出来供大家使用。数据有效性每2分钟更新一次。地址:http://proxy.linuxdba.ltd/all/开源项目地址:https://github.com/jhao104/proxy_pool

    2022年5月29日
    63
  • Map集合转换成实体类对象,实体类对象转换为map集合,互转工具类「建议收藏」

    Map集合转换成实体类对象,实体类对象转换为map集合,互转工具类「建议收藏」注:2019-06-16日增加第六节map与实体互转工具类,直接看第6节;1.调用这个方法BeanMapUtils.mapToBean(),实现map集合转实体类对象;注意:这个方法转换时我这边老是报类型转换错误,引用这段代码没有报错的小伙伴可继续使用,此方法扩展性好,报错的小伙伴请看最下面的一个map转实体类对象方法;//1.通过map构造permiss…

    2022年5月30日
    133
  • 如何更改WIFI频段_wifi5g与2.4g怎么切换

    如何更改WIFI频段_wifi5g与2.4g怎么切换首先打开浏览器并输入IP地址进入路由器管理页面,此时需要输入用户名以及密码进行登录,登录成功以后点击左侧的“无线设置”选项,然后点击“高级无线设置”选项,之后我们就可以修改WiFi的频段了。需要注意的是,目前仅能将无线频段修改为2.4GHz或者5GHz两个频段。如果您的iPhone手机突然不能连接WiFi了,那么您可以打开手机“设置”应用,然后点击“通用”选项,接着点击“还原”选项,进入后选择点击…

    2022年10月20日
    4
  • HashMap的存储结构及原理

    HashMap的存储结构及原理

    2022年1月31日
    43
  • centos创建samba共享_docker共享目录

    centos创建samba共享_docker共享目录内容大纲:samba简介centos上部署samba服务samba服务的配置详解samba服务的共享资源部署samba服务的共享资源权限设置samba服务共享帐号映射一、介绍Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成。SMB(ServerMessagesBlock,信息服务块)是一种在局域网上共…

    2022年9月24日
    4

发表回复

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

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