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


相关推荐

  • 高级C/C++编译技术之读书笔记(三)之动态库设计

    本节思维导图1.关于-fPIC编译器选项1.1-fPIC代表什么“PIC”是位置无关代码(Position-independentCode)的缩写,说到位置无关代码,我们会立马想到加载重定

    2021年12月28日
    43
  • sqlmap下载安装教程_termux 安装kali

    sqlmap下载安装教程_termux 安装kali第一步:下载python:https://www.python.org/downloads/(这里有python各种版本,但是一般建议安装3和2.7)sqlmap:https://github

    2022年8月5日
    6
  • 光流法运动目标检测[通俗易懂]

    光流法运动目标检测[通俗易懂]接上篇,OpenCV视频目标跟踪及背景分割器,本篇介绍OpenCV—python目标跟踪==》光流法回顾:目标跟踪是对摄像头视频中的移动目标进行定位的过程。实时目标跟踪是许多计算机视觉应用的重要任务,如监控、基于感知的用户界面、增强现实、基于对象的视频压缩以及辅助驾驶等。关于实现视频目标跟踪的方法有很多,当跟踪所有移动目标时,帧之间的差异会变的有用;当跟踪视频中移动的手时,基于皮肤颜色的均…

    2022年7月23日
    18
  • TCP和UDP的最完整的区别[通俗易懂]

    TCP和UDP的最完整的区别[通俗易懂]TCP和UDP两种协议的比较汇总

    2022年6月7日
    38
  • SpringCloud笔记:配置Eurake注册中心与高可用集群

    SpringCloud笔记:配置Eurake注册中心与高可用集群SpringCloud是目前非常流行的一个微服务框架,基于springboot,由多个独立模块集合而成。每个模块既可以是一个服务项目,比如会员服务,订单服务等,也可以是公用的API给其他模块使用。可以理解为把一个大的项目拆分成很多小的模块,这些模块通过httpclient+json的形式完成服务之间的通讯,而且每个模块都有自己独立的业务和部署,使得粒度更加精细。五大组件如下:服务注册与发现——…

    2022年5月30日
    58
  • 数据库表设计之用户权限表[通俗易懂]

    数据库表设计之用户权限表[通俗易懂]需求分析1、管理员给用户分配权限,权限数据写到数据库中。2、认证服务在进行用户认证时从数据库读取用户的权限数据(动态数据)user:用户表,存储了系统用户信息,用户类型包括:学生、老师、管理员等role:角色表,存储了系统的角色信息,学生、老师、教学管理员、系统管理员等user_role:用户角色表,一个用户可拥有多个角色,一个角色可被多个用户所拥有menu:记录了菜单及菜单下的权限role_permission:角色权限表,一个角色可拥有多个权限,一个权限可被多个角色所拥有…

    2022年9月29日
    2

发表回复

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

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