
函数名: remove
功 能: 删除一个文件
用 法: int remove(char *filename)
程序例:
#include <stdio.h>int main(void)
{
char file[80]
/* prompt for file name to delete */
printf("File to delete: ")
gets(file)
/* delete the file */
if (remove(file) == 0)
printf("Removed %s.\n",file)
else
perror("remove")
return 0
}
用C语言删除某个文件中的一行内容的原理就是将该行的末尾和
开头找到,
然后将
改行的末尾的所有内容就复制到
改行的开头,使用覆盖的方式来实现删除.
如果实在不懂的话,
你就在改行的末尾
开始写入一定长度的(视改行的字节长度而定)
的转义字符
'\b'
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)