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


相关推荐

  • pycharm如何统一改变量名_pycharm批量修改变量名

    pycharm如何统一改变量名_pycharm批量修改变量名在使用文字工具写小说的时候,如果你想改变主人公的姓名,可以通过快捷方式一键全改,而不用逐个更改。那么在用pycharm编辑代码的时候,该如何将代码中的变量名称进行一键更改呢?按快捷键Ctrl+r,弹出以下页面,在这个页面中我标出了两个红框。左边红框中有两个输入栏,上面的是你的原变量名,下面是你要改为的新变量名;将原变量名和新变量名输入之后,去右边的边框中选择局部替换还是全部替换即可。…

    2022年8月28日
    3
  • java编译和运行

    java编译和运行java应用程序的基本结构 编写源文件 保存源文件 额外附加 编译器(javac.exe) 解释器(java.exe)总结:假如我的B.java源文件在C:\Users\AUSU\Desktop\ts里面一般都是进入到这个目录里面编译解释编译:javacB.java解释:javaB注意:解释不可能以带目录的方式去运行程序,编译可以零…

    2022年6月14日
    29
  • linux 数据恢复软件_常见的数据恢复软件

    linux 数据恢复软件_常见的数据恢复软件一。数据删除命令:rm-rf,将任何数据直接从硬盘删除,且没有任何提示建议做法:把命令参数放到后面:rm-rfi将删除的东西通过mv命令移动到系统下的/temp目录下,然后写个脚本定期执行清除操

    2022年8月3日
    7
  • Nginx 负载均衡配置和策略「建议收藏」

    Nginx 负载均衡配置和策略

    2022年1月24日
    52
  • android 中 TextView的用法[通俗易懂]

    android 中 TextView的用法[通俗易懂]本文讲解TextView4种常见的用法:一.如何显示文本(URL,不同大小、字体、颜色的文本)    activity_main.xml

    2025年7月16日
    2
  • goland的激活码_通用破解码

    goland的激活码_通用破解码,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月15日
    42

发表回复

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

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