Re: for and arrays
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Sun, 27 Jul 2008 22:20:51 +0100
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.
.
- Follow-Ups:
- Re: for and arrays
- From: Serve Lau
- Re: for and arrays
- From: Default User
- Re: for and arrays
- From: Bill Cunningham
- Re: for and arrays
- From: Richard
- Re: for and arrays
- References:
- for and arrays
- From: Bill Cunningham
- Re: for and arrays
- From: Ben Bacarisse
- Re: for and arrays
- From: Bill Cunningham
- Re: for and arrays
- From: Ben Bacarisse
- Re: for and arrays
- From: Bill Cunningham
- Re: for and arrays
- From: Bill Cunningham
- Re: for and arrays
- From: Ben Bacarisse
- Re: for and arrays
- From: Bill Cunningham
- Re: for and arrays
- From: Richard
- for and arrays
- Prev by Date: Re: for and arrays
- Next by Date: Re: Segmentation fault error
- Previous by thread: Re: for and arrays
- Next by thread: Re: for and arrays
- Index(es):
Relevant Pages
|