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()需要第二个 ...
随机推荐
- nios 使用count binary 例程 只是led不闪
系统id有问题的总结: 1, 复位是否正确.(特别使用拨码开关的) 2, 硬件连接是否有问题.(SDRAM的时序约束可以有,也可以没有) 3, 引脚分配是否正确.(SDRAM的dqm就错过一次) 4, ...
- Spring AOP基于注解的“零配置”方式实现
为了在Spring中启动@AspectJ支持,需要在类加载路径下新增两个AspectJ库:aspectjweaver.jar和aspectjrt.jar.除此之外,Spring AOP还需要依赖一个a ...
- web表单disable问题
Web表单提交之disabled问题 例如,有如下表单 <form id="inputForm" action="shorttermrental.action&qu ...
- 【原】Coursera—Andrew Ng机器学习—编程作业 Programming Exercise 2——逻辑回归
作业说明 Exercise 2,Week 3,使用Octave实现逻辑回归模型.数据集 ex2data1.txt ,ex2data2.txt 实现 Sigmoid .代价函数计算Computing ...
- Mac hook—DYLD_INSERT_LIBRARIES
[Mac hook—DYLD_INSERT_LIBRARIES] 1.gcc生成dylib. gcc -dynamiclib -o mysharedlib.dylib mysharedlib.c 2. ...
- codeforce468DIV2——E. Game with String
题目 Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a ...
- CodeForces - 721E
题目大意 现有一个长为 L的数轴,你要从0走到 L 给出n个互不相交的可行域. 你要选择长度为p的段,要求每一个段都要在可行域内. 选完一段之后下一段要么和其相接,要么和其间距至少为t,求问最多能选择 ...
- HTTP 协议中 URI 和 URL 有什么区别?
HTTP 协议中 URI 和 URL 有什么区别? HTTP = Hyper Text Transfer ProtocolURI = Universal Resource IdentifierURL ...
- 744. Find Smallest Letter Greater Than Target 查找比目标字母大的最小字母
[抄题]: Given a list of sorted characters letters containing only lowercase letters, and given a targe ...
- java 实现mysql数据库备份
package com.itenp.gen.action; import java.io.BufferedReader; import java.io.FileInputStream; import ...