fputs()
原型:int fputs(const char *str, FILE *stream) 参数解释:
const char *str : const限制函数内部修改指针指向的数据(在函数形参使用const)
char *str 字符数组
FILE *stream :stream 指向FILE对象的指针
返回值:正确-int非零,错误-EOF(0) 实例:
(1)利用fputs()向控制台输出信息
fputs("Hello world", stdout); stdout - 标准输出流
(2)写入文件
char* filePath = "D:\\student.txt";
FILE * file = NULL;
errno_t err;
if ((err = fopen_s(&file, filePath, "w+")) != 0){
printf_s("文件打开失败。");
exit(0);
}
else{
fputs("Hello world", file);
}
fclose(file); 相似:fputc(),fgets():fgets(buffer, SIZE, stdin) != NULL
fputs()的更多相关文章
- Linux C 字符串输出函数 puts()、fputs()、printf() 详解
一.puts() 函数详解 puts()函数用来向 标准输出设备 (屏幕)写字符串并换行,调用格式为: puts(s); 其中s为字符串变量(字符串数组名或字符串指针). puts()函数的作用与语 ...
- 函数fgets和fputs、fread和fwrite、fscanf和fprintf用法小结 (转)
函数fgets和fputs.fread和fwrite.fscanf和fprintf用法小结 字符串读写函数fgets和fputs 一.读字符串函数fgets函数的功能是从指定的文件中读一个字符串到字符 ...
- fgets和fputs函数
1 函数输入 下面两个函数提供每次输入一行的功能. #include <stdio.h> char *fgets( char *restrict buf, int n, FILE *res ...
- (转载)C++文件读写函数之——fopen、fread和fwrite、fgetc和fputc、fgets和fputs、ftellf和fseek、rewind
http://blog.sina.com.cn/s/blog_61437b3b0102v0bt.html http://blog.csdn.net/chenwk891/article/details/ ...
- C++之函数fgetc和fputc、fgets和fputs、fread和fwrite、fscanf和fprintf用法小结
#include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int ...
- scanf gets fgets区别与联系 puts fputs printf区别与联系
组一:scanf( )函数 gets( )函数 fgets()函数都可用于输入字符串, 组二:printf( )函数 puts( )函数 fputs()函数则用于字符串的输出. 两组内部函数各有 ...
- 关于fputs和fgets的几个细节
C语言中两个标准IO fputs和fgets都是针对行来进行数据的读取的!这里关于这两个IO函数我有几个小细节想在这里和大家分享一下,希望能够对大家产生帮助! 首先贴上这两个函数的函数声明,下面以这两 ...
- php异步加载、多线程fsockopen()、fputs()
index.php <?php function test() { $fp=fsockopen("localhost", 80, $errno, $errstr, 30); ...
- 利用fgets,fputs的回显程序
#include <stdio.h> #define MAXLINE 20 int main(void) { char line[MAXLINE]; while(fgets(line,MA ...
- puts fputs printf的区别
puts()显示字符串时自动在其后添加一个换行符,函数里的参数是一个地址,从该地址向后面输出,直到遇到空字符,所以要确保输出的字符串里要有空字符.与gets()函数一起使用. fputs()需要第二个 ...
随机推荐
- 微信小程序之目录结构
小程序,功能不会太多,页面不会太多. 正常情况下,会包含首页,分类页面,个人中心页面,导航页面,其他页面等等. 我们首先要把页面结构布置好,把架子搭建好. 剩下的就是配置一些内容,小程序的基本信息,接 ...
- Python多线程-队列
队列就是存东西取东西,多用于多线程中 按照顺序 对传入的数据按规定的顺序输出 # -*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" ...
- HDU ACM Fibonacci
Problem Description Fibonacci numbers are well-known as follow: Now given an integer N, please find ...
- C#操作SQLIte数据。
using System; using System.Data; using System.Text.RegularExpressions; using System.Xml; using Syste ...
- spring注解开发的准备工作
- Golang简单写文件操作的四种方法
package main import ( "bufio" //缓存IO "fmt" "io" "io/ioutil" ...
- 高性能的城市定位API接口
如果不需要精准的定位,还有一种通过IP地址获取当前城市的方法,采用新浪的api接口. <script src="http://int.dpool.sina.com.cn/iplooku ...
- js(jquery)右键菜单插件的实现
今天开发一个项目的时候需要一个模拟鼠标右键菜单的功能.也就是在网页点击鼠标右键的时候不是弹出系统的菜单而是我们制定的内容.这样可以拓展右键的功能.实现过程不多说了,写出来的代码和效果如下: js部分: ...
- 734. Sentence Similarity 有字典数组的相似句子
[抄题]: Given two sentences words1, words2 (each represented as an array of strings), and a list of si ...
- 575. Distribute Candies 平均分糖果,但要求种类最多
[抄题]: Given an integer array with even length, where different numbers in this array represent diffe ...