Re: Reading Text Files



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
.



Relevant Pages

  • Re: Reading Text Files
    ... searching. ... Did not your compiler generate some mandatory diagnostics on this ... special meaning in C99, but there is every chance the OP is not using C99. ...
    (comp.lang.c)
  • Re: Reading Text Files
    ... searching. ... Did not your compiler generate some mandatory diagnostics on this ... special meaning in C99, but there is every chance the OP is not using C99. ...
    (comp.lang.c)
  • Re: Microsoft throws in the towel on Vista
    ... Vista Home Premium comes in a 32-bit flavor and a 64-bit flavor. ... I'm not sure if the compiler will honor those requests if you have plenty of registers. ... I would say no. OpenGL 1.4 is there, but what Windows gives you by default is OpenGL-over-DirectX, and that's got to take a performance hit. ...
    (comp.sys.mac.advocacy)
  • Re: 2 identical projects ---> 2 compiled exec causing Vista different response
    ... The compiled executive runs fine from within Inno Setup in Vista ... How that simple underscore can influance the compiler output and as a ...
    (microsoft.public.vb.general.discussion)
  • Re: RAM access limits under 64bit
    ... You have available whatever Windows chooses to make available to you. ... There are two flavors of Windows Vista, ... If the compiler needs to create an array copy on the stack, ... Visual Studio 2005/2008 Professional Edition does not install x64 support by default, ...
    (comp.lang.fortran)

Loading