hi 2 all,
i have placed a file in a folder in BIN, How can i no that if that file is present there or not??

Do reply me soon ...
Thx ..take carez n keep smiling all .. :)

attempt to open it with fopen() or ifstream::open(), depending on C or C++ program.

Here is an extract from K & R C programming Tutorials

A file is opened by a call to the library function fopen(): this is available automatically when the library file <stdio.h> is included. There are two stages to opening a file: firstly a file portal must be found so that a program can access information from a file at all. Secondly the file must be physically located on a disk or as a device or whatever. The fopen() function performs both of these services and, if, in fact, the file it attempts to open does not exist, that file is created anew. The syntax of the fopen() function is:
FILE *returnpointer;
returnpointer = fopen("filename","mode");

So better keep in mind that if the file is not present a new one with the same name will be created.

Bye.

> So better keep in mind that if the file is not present a new one with the same name will be created.
Not if you're opening it for reading it won't.

> So better keep in mind that if the file is not present a new one with the same name will be created.
Not if you're opening it for reading it won't.

Damn how could i have ignored it, yes thats true.
Thanks for the correction.

[deleted]

thx for ur help but i am still in confusion .. i am using ofstream functon of ifstream header file ... its syntax is

ofstream buffer ("filename" , file mode)

but since file is placed in a folder in bin so where can i define pth for file as ofstream function can locate files only in BIN folder .

thx for ur help but i am still in confusion .. i am using ofstream functon of ifstream header file ... its syntax is

ofstream buffer ("filename" , file mode)

but since file is placed in a folder in bin so where can i define pth for file as ofstream function can locate files only in BIN folder .

If u want the buffer ("fileName", "fileMode"); to work at a custom defined location, for eg. BIN in your case then you can try somthing like this: buffer ("c:/c compiler/BIN / file.txt", "w"); Hope it helped,
bye.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.