Re: for and arrays



Richard<rgrdev@xxxxxxxxx> writes:

<snip program>
You don't know how to include spaces?

ROTFLM. It just gets better.

I don't understand this. If you think Bill is clever fiction, why are
you replying with serious suggestions (see below)? If you think he is
genuinely struggling to learn, then why laugh at his attempts. It
seems cruel.

#include <stdio.h>

int main (void) {
char a[]={'0','1','2','3','4','5','6'};
printf("%s\n",a);
}

Bill

Maybe you could describe, in words, what you are doing there? Did you
bother your arse to look at the data structures in a debugger yet as
advised?

He said it worked so presumably if he'd looked he'd see what he expects
to see. For example, in gdb it shows:

(gdb) print a
$1 = "0123456"
(gdb) print a[6]
$2 = 54 '6'
(gdb) print a[7]
$3 = 0 '\0'

You have to know what's wrong to ask the right question:

(gdb) print sizeof a
$4 = 7

This is one problem with using a debugger to learn with -- it shows
you only what happens not what your code means.

--
Ben.
.



Relevant Pages

  • Re: for and arrays
    ... If you think Bill is clever fiction, ... For example, in gdb it shows: ... Bill is that he heasn't a clue what "works" means since half the time he ... The debugger will show the same as the execution run which he says ...
    (comp.lang.c)
  • Re: for and arrays
    ... If you think Bill is clever fiction, ... bother your arse to look at the data structures in a debugger yet as ... For example, in gdb it shows: ... This is one problem with using a debugger to learn with -- it shows ...
    (comp.lang.c)
  • Re: for and arrays
    ... program flow using a debugger. ... Allows you to modify run time variables to "push" ... I can see NO negative aspects of someone like Bill ... It does not have to be gdb. ...
    (comp.lang.c)
  • Re: seg fault
    ... Maybe time for you to give up Bill? ... On windows then switched to my linux system and started to use gdb ... boot. ...
    (comp.lang.c)
  • Re: seg fault
    ... I've never used a debugger, ever, but I thought I'd give this a go. ... First problem was to get gdb for Windows, but 10-15 mins on google and ... or -ggdb switches I use for gcc. ... where bugs could be due also to errors in the compiler, ...
    (comp.lang.c)