English 中文(简体)
fopen()不与编辑工作良好
原标题:fopen() does not working well with gvim editor
  • 时间:2011-04-01 10:17:51
  •  标签:
  • c
  • windows
  • vim

第一,我可以说得很好。 请理解:

当我试图打开文本档案,以用斜线书写一些东西时,例如FILE *f = f open(“data.txt”,“w”);,我无法找到数据。 txt文档任何地方,不仅现有目录,而且在Windows探测器上。 BUT. 未经档案的劳动罚款:

我有疑虑,因此,我曾尝试过这个<代码>FILE *f = f open(“c:my. data.txt”、“w”);。 具体指明道路、工作良好!

我知道,文本档案存放在与执行档案夹相同的夹中。

Of course, Other IDE is working very well.(MSVS or Dev C++) What s my problem??

(一米使用Windows7和gvim)

// Modification
// source code

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    FILE *f = NULL;
    int name[10];

    if((f = fopen("data.txt", "w")) == NULL){
        printf("sorry..
");
        system("pause");
        exit(1);
    }
    fprintf(f, "%s
", "Dennis");
    fclose(f);

    if((f = fopen("data.txt", "r")) == NULL){
        printf("sorry2..
");
        system("pause");
        exit(1);
    }
    fscanf(f, "%s", name);
    printf("%s
", name);

    fclose(f);
    system("pause");
    return 0;
} // I think it s no problem. I ve tried different ways to try several times.

I will compile this -> map :! gcc % -o %<.exe (in vimrc. file) Push Cntl + F9. Vim 7.3, MingW 0.1-alpha-5. I just coding some source code, there are fopen(), fprintf() and fscanf(). When I tried to write on text file that I opened file, something was written there. but I could not see the text file. And, I tried to read the text file that I wrote file, although It was open, could not be read. Windows Explorer could not find the text file.

最佳回答

I can only guess, but I think your problem is that gvim doesn t change into the directory of your file.

这方面的容易补救:autochdir

利用Windows 搜索应用,查找您的数据。 如果你从开始的菜单开始就开始,则应在“C:ProgramDataMicrosoftvilStart MenuProgramsVim 7.3”上。

问题回答

暂无回答




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签