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)
上一篇 2022年8月30日 下午11:46
下一篇 2022年8月30日 下午11:46


相关推荐

  • maven热部署[通俗易懂]

    maven热部署[通俗易懂]1.热部署:&lt;dependency&gt;&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;&lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;&lt;optional&gt;true&…

    2022年5月21日
    44
  • esp8266架构_esp8266能做什么

    esp8266架构_esp8266能做什么    欢迎大家来到ESP8266的世界,从现在开始,笔者将带领大家慢慢揭开ESP8266神秘的面纱。1.简介    从笔者的角度来说,ESP8266这个词可以理解为ESP8266EX芯片(当然,后面也有可能出现了其他芯片,这里首推ESP8266EX)以及依赖ESP8266EX芯片开发的系列模组的简称。    ESP8266EX是由乐鑫信息科技公司(Espressif)出品的一款应用于物联…

    2022年8月13日
    10
  • Redis lua教程

    Redis lua教程看这个文章之前请确认自己已经掌握了 lua 的基本语法 如果不会先去看看 lua 的教程 很简单 在基本的操作 redis 中 看一下的目录就知道了 看完前面的部分就暂时够用了 菜鸟教程 https www runoob com lua lua tables htm

    2026年3月26日
    2
  • linux双网卡架设FTP,LINUX系统上架设FTP服务器[通俗易懂]

    linux双网卡架设FTP,LINUX系统上架设FTP服务器[通俗易懂]CentOS上搭建FTP服务器服务器软件:vsftpd简要说明:vsftpd是linux下的一款小巧轻快,安全易用的FTP服务器软件,是一款在各个LINUX发行版中最受推崇的FTP服务器软件。至于它的安装教程,网络上也是数不胜数,每个教程都有各自的优缺点,祥哥特意做了个总结,取别人之长处,尽量做到菜鸟级别的教程。当你看见祥哥的这篇文章,能更好的使用和运用VSFTPD。下面正题开始。安装vsftpd…

    2022年7月21日
    13
  • 录屏做成gif的软件_下载录屏软件

    录屏做成gif的软件_下载录屏软件推荐一款神奇的gif录屏小软件,开源免费安装后打开即可录屏支持win,macos下载:https://www.cockos.com/licecap/github:https://github.com/justinfrankel/licecap

    2025年12月4日
    5
  • 中位数和众数例题_中位数题

    中位数和众数例题_中位数题—一.填空题1.某班8名学生完成作业所需时间分别为:75,70,90,70,70,58,80,55(单位:分),则这组数据的众数为____,中位数为_______,平均数为_________2.已知一组数据1,0,-3,2,-6,5,这组数据的中位数为___________.3.若数据10,12,9,-1,4,8,10,12,x的众数是12,则x=__________.4.数据3,4,6,8…

    2025年12月11日
    4

发表回复

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

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