C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to open a file on a perticular path Posted by d_deepak on 11 Oct 2006 at 11:02 PM
how to open a file on a perticular path i.e.
if I want to open a file stored on d:\deepak\dd then how to use fopen()
whether it should be like that
fp=fopen("d:\deepak\dd\d1.dat","r+")

plz help

Report
Re: how to open a file on a perticular path Posted by Lundin on 11 Oct 2006 at 11:24 PM
: how to open a file on a perticular path i.e.
: if I want to open a file stored on d:\deepak\dd then how to use fopen()
: whether it should be like that
: fp=fopen("d:\deepak\dd\d1.dat","r+")
:
: plz help
:
:

fp=fopen("d:\\deepak\\dd\\d1.dat","r+")
Report
Re: how to open a file on a perticular path Posted by bosebonas on 12 Oct 2006 at 8:38 AM
: : how to open a file on a perticular path i.e.
: : if I want to open a file stored on d:\deepak\dd then how to use fopen()
: : whether it should be like that
: : fp=fopen("d:\deepak\dd\d1.dat","r+")
: :
: : plz help
: :
: :
:
: fp=fopen("d:\\deepak\\dd\\d1.dat","r+")
:
If you want to acces a file using the old C way then do it this way :
FILE *fp;
fp=fopen ("D:\deepak\dd\d1.dat","r+");
that is it.


Report
Re: how to open a file on a perticular path Posted by stephl on 12 Oct 2006 at 11:55 AM
: : : how to open a file on a perticular path i.e.
: : : if I want to open a file stored on d:\deepak\dd then how to use fopen()
: : : whether it should be like that
: : : fp=fopen("d:\deepak\dd\d1.dat","r+")
: : :
: : : plz help
: : :
: : :
: :
: : fp=fopen("d:\\deepak\\dd\\d1.dat","r+")
: :
: If you want to acces a file using the old C way then do it this way :
: FILE *fp;
: fp=fopen ("D:\deepak\dd\d1.dat","r+");
: that is it.
:
No, as Lundin wrote it, each '\' must be replaced by '\\' in the path.
Steph
Report
Re: how to open a file on a perticular path Posted by Lundin on 12 Oct 2006 at 11:09 PM
: : : how to open a file on a perticular path i.e.
: : : if I want to open a file stored on d:\deepak\dd then how to use fopen()
: : : whether it should be like that
: : : fp=fopen("d:\deepak\dd\d1.dat","r+")
: : :
: : : plz help
: : :
: : :
: :
: : fp=fopen("d:\\deepak\\dd\\d1.dat","r+")
: :
: If you want to acces a file using the old C way then do it this way :
: FILE *fp;
: fp=fopen ("D:\deepak\dd\d1.dat","r+");
: that is it.
:


I don't know what "the C old way" is. Follow ANSI C and use the syntax I suggested.

Report
Re: how to open a file on a perticular path Posted by bosebonas on 13 Oct 2006 at 7:06 AM
i just want to say i was mistaken.I agree you did it the right way.
I am sorry for the misunderstanding.

: : : : how to open a file on a perticular path i.e.
: : : : if I want to open a file stored on d:\deepak\dd then how to use fopen()
: : : : whether it should be like that
: : : : fp=fopen("d:\deepak\dd\d1.dat","r+")
: : : :
: : : : plz help
: : : :
: : : :
: : :
: : : fp=fopen("d:\\deepak\\dd\\d1.dat","r+")
: : :
: : If you want to acces a file using the old C way then do it this way :
: : FILE *fp;
: : fp=fopen ("D:\deepak\dd\d1.dat","r+");
: : that is it.
: :
:
:
: I don't know what "the C old way" is. Follow ANSI C and use the syntax I suggested.
:
:

Report
Re: how to open a file on a perticular path Posted by bluj91 on 15 Nov 2006 at 3:39 PM
This message was edited by bluj91 at 2006-11-15 15:40:57

: i just want to say i was mistaken.I agree you did it the right way.
: I am sorry for the misunderstanding.
:
: : : : : how to open a file on a perticular path i.e.
: : : : : if I want to open a file stored on d:\deepak\dd then how to use fopen()
: : : : : whether it should be like that
: : : : : fp=fopen("d:\deepak\dd\d1.dat","r+")
: : : : :
: : : : : plz help
: : : : :
: : : : :
: : : :
: : : : fp=fopen("d:\\deepak\\dd\\d1.dat","r+")
: : : :
: : : If you want to acces a file using the old C way then do it this way :
: : : FILE *fp;
: : : fp=fopen ("D:\deepak\dd\d1.dat","r+");
: : : that is it.
: : :
: :
: :
: : I don't know what "the C old way" is. Follow ANSI C and use the syntax I suggested.
: :
: :
:
:

You see under c \ is an escape code and hence be foloowed somethingy. Example printing \a will give you a head ache. Print \n will print a line break printing \r will return the carriage. Lot's of them there are. but in you case in order to put a backslash, \, in C or C++ you must use the escape code \\ for the backslash.

And I think this has been implemented long before the dawn of time, ie. this is common 'the Old C'.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.