写文件换行
来源:互联网 发布:windows 开机启动 编辑:程序博客网 时间:2024/05/23 15:06
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
FILE *fp;
char ch;
int count=0;
if((fp=fopen("test1.txt","wt"))==NULL)
{
printf("Cannot open file!\n");
getch();
exit(1);
}
printf("Please input a character:");
//ch=getchar();
/* while(ch!='\n')
{
fputc(ch,fp);
putchar(ch);
ch=getchar();
}*/
while((ch=getchar())!='\n')
{
fputc(ch,fp);
count++;
if(count%5==0)
fputc( '\n', fp );
}
/* while((ch=getchar())!='\n')
{
fputc(ch,fp);
count++;
if(scanf("%d",&cc)%5==0)
fputc( '\n', fp );
}
*/
// fputc( '\r', fp );
// fputc( '\n', fp );
fclose(fp);
system("pause");
return 0;
}
例如,如输入一串字符abcjdkadk;adkl;adkl;ado,运行结果:
abcjd
kadk;
adkl;
adkl;
ado
- 写文件自动换行
- python 写文件换行
- 写文件换行
- PHP写文件换行
- Wince应用程序写文件换行
- java写.txt文件换行
- 写.txt文件不能换行问题
- pyhton2.7 写文件为何不能换行
- 关于php 写文件 不换行 的问题
- FileWriter(String) 写文件换行的方法。
- 关于写回车换行到unicode文件的问题。
- Java写到.txt文件,如何实现换行
- Java写到.txt文件,如何实现换行
- Java写到.txt文件,如何实现换行
- Java写到.txt文件,如何实现换行
- java中用StringBuffer写文件实现自动换行
- Java写到.txt文件,如何实现换行
- Java写到.txt文件,如何实现换行
- 【转】用 grep 恢复误删的文本文件
- 11, Objective-C语法property详解
- USACO Chapter1-Getting started Section 1.3
- 12,Objective-C语法之KVC的使用
- GoAgent设置RC4加密
- 写文件换行
- sublime配置全攻略
- [MacrayKV] An innovative parallel testing framework
- 13,Objective-C语法之KVO的使用
- 14,Objective-C语法之代码块(block)的使用
- LeetCode题解:N-Queens I and II
- 15,Objective-C语法之Category的使用
- Oracle 11Gr1监听报错TNS-12542 12560 00512
- Android 支持不同屏幕的方法