3个回答
展开全部
用_access函数判断,再次打开时的情况要看你第一次的打开方式了,如果上次用的是非独占打开,那没问题,如果是独占打开,会打开失败
Example
/* ACCESS.C: This example uses _access to check the
* file named "ACCESS.C" to see if it exists and if
* writing is allowed.
*/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
/* Check for existence */
if( (_access( "ACCESS.C", 0 )) != -1 )
{
printf( "File ACCESS.C exists\n" );
/* Check for write permission */
if( (_access( "ACCESS.C", 2 )) != -1 )
printf( "File ACCESS.C has write permission\n" );
}
}
Example
/* ACCESS.C: This example uses _access to check the
* file named "ACCESS.C" to see if it exists and if
* writing is allowed.
*/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
/* Check for existence */
if( (_access( "ACCESS.C", 0 )) != -1 )
{
printf( "File ACCESS.C exists\n" );
/* Check for write permission */
if( (_access( "ACCESS.C", 2 )) != -1 )
printf( "File ACCESS.C has write permission\n" );
}
}
展开全部
打开文件要用FOPEN吧
FILE *fp;
fp = fopen( "Student.dat", "wb" );
先判断这个指针是否为NULL就行了啊~
FILE *fp;
fp = fopen( "Student.dat", "wb" );
先判断这个指针是否为NULL就行了啊~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
判断能否再次打开就行了!!
if ( fp == 0 )
fprintf (stderr, "Eorro");
if ( fp == 0 )
fprintf (stderr, "Eorro");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询