D - Errors in simple program.
- madamephreaker hotmail.com (19/19) Mar 20 2003 When I use printf in the way i'm doing now(see code) it crashes flat out...
- Burton Radons (2/3) Mar 20 2003 Use "%.*s\n".
- madamephreaker hotmail.com (8/11) Mar 20 2003 "%.*s\n".
- madamephreaker hotmail.com (11/20) Mar 20 2003 Radons
- Walter (6/7) Mar 21 2003 The input[] is a dynamic array, which consists of a length field and a
When I use printf in the way i'm doing now(see code) it crashes flat out. If i just do "printf(input);" it works until it gets to a blank line. In all cases it gives "Error: Access Violation" when it crashes. --- Begin hello.d import c.stdio; import stream; int main( char[][] args ) { char[] input=""; File myFile = new File(args[1]); while( ! myFile.eof() ) { input = myFile.readLine(); printf("%s\n", input); } myFile.close(); return 0; } --- End hello.d
Mar 20 2003
madamephreaker hotmail.com wrote:printf("%s\n", input);Use "%.*s\n".
Mar 20 2003
In article <b5dglk$28cu$1 digitaldaemon.com>, Burton Radons says...madamephreaker hotmail.com wrote:"%.*s\n".printf("%s\n", input);UseWhat about the multiple lines? and when i use printf(input); ? input isn't always declared? I'm assuming since result in the stream class is a resizable array when it doesn't get anything it it it's a pointer to an array of length zero? Thus accessing it blows up? Why would "%.*s" fix that?
Mar 20 2003
In article <b5dm68$2c4e$1 digitaldaemon.com>, madamephreaker hotmail.com says...In article <b5dglk$28cu$1 digitaldaemon.com>, BurtonRadonssays...input);madamephreaker hotmail.com wrote:printf("%s\n",I just switched to using that now, and it works. to some extent.. If the last line of the file doesn't end in a newline it spews this out: not enough data in stream Although looking at it more i think dli 0.1.2 just has an old version of phobos. (I tried updating but it failed to compile parts of phobos then)Use"%.*s\n".
Mar 20 2003
<madamephreaker hotmail.com> wrote in message news:b5dm68$2c4e$1 digitaldaemon.com...Why would "%.*s" fix that?The input[] is a dynamic array, which consists of a length field and a pointer to the data. %s expects a pointer to a null terminated string. %.*s expects two parameters, a length and a pointer, which fits perfectly with D arrays.
Mar 21 2003