Re: Reading Text Files
- From: Barry Schwarz <schwarzb@xxxxxxxx>
- Date: Mon, 02 Mar 2009 21:10:57 -0800
On Mon, 2 Mar 2009 20:49:20 -0000, "Mike" <gdf@xxxxxxx> wrote:
Hi,
I'm trying to create a C function that will read a text file but I keep
getting fopen() = NULL
I've tried my own code and when that didn't work I tried code off various
websites and they keep giving the same result.
The file was created in notepad, saved as a .txt and contains only "abcd"
without quotes.
Only thing I can think of is that the program doesn't have rights to access
the file....possibly because it's Vista? But nothing turns up after
searching.
The code is written:
FILE *fp;
fp = fopen( "C:\Users\<Username>\Documents\R.txt", "r" );
Did not your compiler generate some mandatory diagnostics on this
line? If not, you need to up the warning level. If yes, why did you
ignore them?
Is there anyway to find out why it can't open the file?
You could look in your reference for what the C language does with a
'\' character in a string literal.
--
Remove del for email
.
- Follow-Ups:
- Re: Reading Text Files
- From: Flash Gordon
- Re: Reading Text Files
- References:
- Reading Text Files
- From: Mike
- Reading Text Files
- Prev by Date: micro to declare and initialize a struct pointer does not work, why?
- Next by Date: Re: Leading padding in unions
- Previous by thread: Re: Reading Text Files
- Next by thread: Re: Reading Text Files
- Index(es):
Relevant Pages
|
Loading