在下急着需要分行读写文本文件内容的例子,是在标准C下,同时也需要进行块读写的,也是在标准C下的!谢谢!
解决方案 »
- CStdioFile类的ReadString方法问题
- Recordset->Open(...)老是报错:0xC0000005:Acess Violution
- 如何把网口虚拟成串口?
- 心跳包是什么东东?
- 为什么不能使用TrackMouseEvent()?
- VS.net和Office XP的MENU是怎么作的
- 当用c++编程时,能不能不用回收内存?100分
- 请教各位:VC中如何确定错误的范围????????
- 焦点失去的情况下如何使用快捷键的问题
- 怎样在MFC程序中使用DirectX(DirectSound)?
- 请教在VC MDI程序中,怎样在文件打开对话框中自定义过滤文件的方法
- 关于IP头中的记录路由选项
{
FILE *stream;
char line[100]; if( (stream = fopen( "crt_fgets.txt", "r" )) != NULL )
{
if( fgets( line, 100, stream ) == NULL)
printf( "fgets error\n" );
else
printf( "%s", line);
fclose( stream );
}
}
{
FILE *stream;
char list[30];
int i, numread, numwritten; /* Open file in text mode: */
if( (stream = fopen( "fread.out", "w+t" )) != NULL )
{
for ( i = 0; i < 25; i++ )
list[i] = (char)('z' - i);
/* Write 25 characters to stream */
numwritten = fwrite( list, sizeof( char ), 25, stream );
printf( "Wrote %d items\n", numwritten );
fclose( stream ); }
else
printf( "Problem opening the file\n" ); if( (stream = fopen( "fread.out", "r+t" )) != NULL )
{
/* Attempt to read in 25 characters */
numread = fread( list, sizeof( char ), 25, stream );
printf( "Number of items read = %d\n", numread );
printf( "Contents of buffer = %.25s\n", list );
fclose( stream );
}
else
printf( "File could not be opened\n" );
}
不好意思,是在那里实现行读写呢?
fwrite的时候加上回车、换行就是写一行了