www.digitalmars.com         C & C++   DMDScript  

D - Problems opening a file

reply kinghajj <kinghajj_member pathlink.com> writes:
here's the problem-code:

this(String s,char *m)
{
if( (file = fopen(s.strGet(),m)) == nullf)
{
printf("ERROR: Could not open file.");
assert(0);
}
}
It's a constructor of a class 'File'; 'String' is another class. strGet()
returns the string, variable type 'string' (char[]). I can't see what's wrong
with this, but whenever I try to open a file like this I get the error "ERROR:
Could not open file.".

nullf is a file used for comparison between the two files (to see if there's a
problem).
Apr 02 2004
parent Manfred Nowak <svv1999 hotmail.com> writes:
kinghajj wrote:

[...]
 if( (file = fopen(s.strGet(),m)) == nullf)

 returns the string, variable type 'string' (char[])

Probably fopen expects a C string ( char*) not a D string (char[]). So long!
Apr 02 2004