标题:fopen("F:\1.txt","r")为什么会打开失败呢
取消只看楼主
swy147900
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-10-4
结帖率:100%
已结贴  问题点数:2 回复次数:2 
fopen("F:\1.txt","r")为什么会打开失败呢



#include "stdio.h"
#include "conio.h"



{
    FILE *fo;
    fo=fopen("F:\sun\1.txt","r");
    if(fo==NULL)
    {
        printf("failed to open the file");
    }
    else
    {
        printf("congratulations!");
        fclose(fo);
    }
        getch();
 }******************************************
#include "Stdio.h"
main()
{
     char a[20];
     FILE *fp;
     printf("enter name of file:");
     scanf("%s",a);
     fp=fopen(a,"r");
     if(fp==NULL)
     {
          printf("can't open this file:%s",a);
          exit(0);
     }else
    {
        printf("Congratulations!The file %s is opened!",a);
        fclose(fp);
    }
    getch();
}


这样为什么输入F:\sun\1.txt就没有错误了呢
*************************
搜索更多相关主题的帖子: 失败 fopen 
2009-10-04 21:39
swy147900
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-10-4
得分:0 
回复 2楼 StarWing83
谢谢了果然如此,O(∩_∩)O哈哈~,那为什么在命令提示符下输入F:\sun\1.txt就好使了呢
2009-10-04 21:47
swy147900
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-10-4
得分:0 
为啥没人回答了呢....
2009-10-04 22:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-287613-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.060212 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved