1. Errrr... You know what I am speaking about.
Hi all.
Yesterday I was debugging a C program. The program contained these lines:
short Buffer[NCOD][BUFSIZE][NDIFF];
............
short (*b)[BUFSIZE][NDIFF];
............
int j;
b = Buffer[j];
This failed, and I did not understand why.
C, when it deals with pointers, is sometimes a pain in the neck. But instead of
blaming the language, the compliler, its cryptic messages and so on, I started to
scratch my head, and after a while I found my error, corrected it, and got the
program running.
What has this to do with this forum?
Well, I hope you understand.
Best regards.
Regards.
2. Re: Errrr... You know what I am speaking about.
Ricardo Forno wrote:
>
> Hi all.
> Yesterday I was debugging a C program. The program contained these lines:
>
> short Buffer[NCOD][BUFSIZE][NDIFF];
> ............
> short (*b)[BUFSIZE][NDIFF];
> ............
> int j;
> b = Buffer[j];
>
> This failed, and I did not understand why.
> C, when it deals with pointers, is sometimes a pain in the neck. But instead
> of blaming the language, the compliler, its cryptic messages and so on, I
> started
> to scratch my head, and after a while I found my error, corrected it, and got
> the program running.
> What has this to do with this forum?
> Well, I hope you understand.
> Best regards.
> Regards.
Yes, I think I *do* know what you are talking about. What was the error, BTW?
The parentheses around *b?
--
A complex system that works is invariably found to have evolved from a simple
system that works.
--John Gall's 15th law of Systemantics.
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.
3. Re: Errrr... You know what I am speaking about.
- Posted by Ricardo Forno <ricardoforno at tutopi??com>
Sep 26, 2007
-
Last edited Sep 27, 2007
Jason Gade wrote:
<snip>
> Yes, I think I *do* know what you are talking about. What was the error, BTW?
> The parentheses around *b?
<snip>
No. The right sentence is:
short (*b)[NDIFF];
The [BUFSIZE] had not to be there.
Regards.