cpubbs论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

LabVIEW+单片机学习套件全套教程资料下载[免费]LabVIEW论坛精华列表贴USB0816数据采集卡《LabVIEW宝典》
LabWindows/CVI论坛精华贴NET0816以太网数据采集卡RC0210远程设备授权系统 关闭关停锁定打开设备 户外分布式数据采集
NET1624低速高精度以太网数据采集卡WIFI0824SD无线WIFI网络数据采集卡脱机运行 SD存储 小尺寸微型 串口采集远程采集 安卓 手持移动采集 纪录仪
查看: 1250|回复: 4

将光标移到行尾

[复制链接]
发表于 2009-4-11 11:12:45 | 显示全部楼层 |阅读模式
我想向txt中写数据,但是每写一行,光标就跑到行首了,请问怎么将光标移到行尾?还有怎么换行
发表于 2009-4-11 18:19:29 | 显示全部楼层
SetFilePtr (, 0, 2);

用它试试!
发表于 2009-4-11 18:19:38 | 显示全部楼层
Moves the file pointer for the file specified by fileHandle to a location that is offset bytes from origin. Returns the offset of the new file pointer position from the beginning of the file.
You can use SetFilePtr to obtain the file size by setting offset to 0 and origin to 2. In this case, the return value indicates the file size, and the file pointer points to the end of the file.
You can position the file pointer beyond the end of the file. Intermediate bytes, bytes between the old end of file and the new end of file, contain values that might vary. An attempt to position the file pointer before the beginning of the file causes the function to return an error.
If the file is a device that does not support random access, such as the Standard Input, the function returns a value that might vary.
Example/* Open or create the file c:\TEST.DAT, move 10 bytes into the file, and write a string to the file. */

/* Note: In C, use \\ in pathname instead of \. */

int handle, result;
long position;

handle = OpenFile("c:\\TEST.DAT", 0, 2, 1);
if (handle == –1){
   FmtOut("error opening file");
   exit(1);
}
position = SetFilePtr(handle, 10L, 0);
if (position == 10){
   result = WriteFile(handle, "Hello, World!", 13);
   if (result == -1)
      FmtOut("error writing to file");
}
else
   FmtOut("error positioning file pointer");
CloseFile(handle);

file:///c:/program%20files/national%20instruments/cvi85/bin/libref/dot.gif Prototype file:///c:/program%20files/national%20instruments/cvi85/bin/libref/dot.gif
long SetFilePtr (int File_Handle, long Offset, int Origin);
 楼主| 发表于 2009-4-11 22:04:28 | 显示全部楼层
谢谢楼上的,我用fprintf直接换行做出来了 3# cpubbs
发表于 2009-4-11 22:18:05 | 显示全部楼层
换行可以直接在数据后面加\n就可以了!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cpubbs论坛. ( 粤ICP备09171248号 )

GMT+8, 2025-4-21 05:32 , Processed in 1.249140 second(s), 6 queries , Gzip On, File On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表