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()需要第二个 ...
随机推荐
- nginx 配置隐藏index.php效果
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; } } 完整如下 server { li ...
- php浏览器端调试输出方法
1.利用js打印到浏览器控制台 <?php function console_log($data) { if (is_array($data) || is_object($data)) ...
- python与桶排序
问题提出: 将以下数据: 6, 8, 2, 3, 4, 0, 9, 1, 5,1 按从小到达排列. 桶排序原理: 桶排序也叫计数排序,简单来说,就是将数据集里面所有元素按顺序列举出来,然后统计元素出现 ...
- linux 动态静态库
库从本质上来说是一种可执行代码的二进制格式,可以被载入内存中执行.库分静态库和动态库两种. 1 静态库和动态库的区别1.1. 静态函数库 (1)静态函数库的名字一般是lib[name].a( ...
- leetcode378
public class Solution { public int KthSmallest(int[,] matrix, int k) { ); ); var list = new List< ...
- 查看自己U盘格式
转自:https://zhidao.baidu.com/question/220844418.html 选中U盘后,鼠标右键单击,选项菜单中点击属性,出的的属性窗口中的“常规”项里边就有U盘的基本信息 ...
- IDEA中快速排除maven依赖
选中该模块 点击show dependenties 切换试图 选中要排除的依赖,右击 选择Execlude,然后选择需要在哪个模块添加排除依赖 完成
- 【问题】/usr/bin/env: php: 没有那个文件或目录
php不是默认安装的,在使用symfony创建新项目时,出现这个提示. [root@localhost html]# symfony demo /usr/bin/env: php: 没有那个文件或目录 ...
- java Integer类的缓存(转)
首先看一段代码(使用JDK 5),如下: public class Hello { public static void main(String[] args) { int a = 1000, b = ...
- JBPM具体应用之decision节点的使用
JBPM工作流引擎为我们提供了许多的节点应用,每一个节点都有其不同的作用,其中有四个比较常用的节点,他们分别decision,fork,state和task.在本文中我们先介绍decision节点,余 ...