access violation error

Michael P. baseball.mjp at gmail.com
Wed Aug 13 18:26:48 PDT 2008


> > Sorry I made you angry...
> >
> 
> No, you didn't. It just proves that C functions are unsafe and hard to use.
> 
> > I changed all the scanfs to din.readfs and everything worked okay...  
> > does that solve my passing a pointer to a string to function that  
> > accepts a pointer to a char?
> 
> Yes, I think.
> 
> > I guess I should check the documentation for some stuff like that.
> 
> Well, you should understand what are you doing when using C library. It is  
> unsafe and very error-prone.
> In fact, you were doing fine, just used wrong function. Compare the  
> following:
> 
> char[] buffer; scanf("%s", &buffer); vs char[] buffer; readf("%s",  
> &buffer);
> 
> They are almost the same, but D version (readf) is an order of magnitude  
> smarter and safer because of type-safe variadic functions.


Okay, thanks, I'll be using readf from now on. :D
-Michael P.


More information about the Digitalmars-d-learn mailing list