怎样将一个char*p, p所指向的内容以字节的方式写在文件里????
解决方案 »
- 一个按钮点了开始,怎么让另外一个按钮点停止。
- OPOS driver for VFD Display
- 今天开始上班了,第一份正式工作,散分
- 关于opengl中的鼠标控制
- 内存块清零问题
- 请问:如何在VC里打开写字板程序并显示指定目录下的文本?
- 连接问题!急!100分在线等!!!!
- 翻译几行代码到VB!
- 请问哪位老大能为小女提供VC++编译调试出错信息及解决问题的资料?
- 我写的DCOM组件,在DCOMCNFG界面里面 在位置选项卡中,关于“在这台计算机上运行应用程序”一项是灰的,无法选择
- 为什么不能弹对话框?
- getline()和cin()都要求用户输入完后打一回车,我现在只要输入一个字符,有什么办法让用户不打回车,一按键就完成输入?类似于Press any
fwrite (p, sizeof (char), strlen (p), fp);
fclose (fp);
{
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" );
}
FILE *_wfopen( const wchar_t *filename, const wchar_t *mode );将mode设置为b,表示:Open in binary (untranslated) mode; translations involving carriage-return and linefeed characters are suppressed.