strange behavior with **double

R

Richard Tobin

C is a relatively simple, logical, and straightforward language.
[/QUOTE]
"C is quirky, flawed and an enormous success"

These are not contradictory due to the "relatively" in the first
statement.

There are a few languages that are simpler and more logical than C,
and a whole lot that are the opposite.

-- Richard
 
B

Barry Schwarz

HA HA HA. You made me laugh. Why did you say that ? Explain.

Because in a previous post you said that you didn't understand why you
could use the expression coef[j] when coef was a double** and not a
2D array of double. In C the expression x is defined to be exactly
the same as *(x+i). This is a very fundamental basic concept in C.
Array subscripting
in C works by converting the array to a pointer (to its first element)
and then adding the subscript and dereferencing.

I never use array because one day gcc ask me a cast because I was
assuming that an int[] is an int *, but for it no, it's two different
types.

The fact that types are different does not prevent them from sharing
syntax. int and double are two different types yet share the same +
operator.

You really do need to learn the basics.


Remove del for email
 
I

iesvs

You really do need to learn the basics.

Stop to say that, it's stupid. I have nothing to learn in C. Yeah I
not use the arrays, but they are useless. So yes you could learn me
many things about them, but I don't care I don't use. Pointer rules,
that's all. Many of my friends will laugh if I say them than some give
me the advice to learn basic C.
 
R

Richard Heathfield

(e-mail address removed) said:
Stop to say that, it's stupid. I have nothing to learn in C.

Then you have no need for the assistance of people in this newsgroup with
your questions about C. When you said:

"I got a double ** (double **coef). And gcc accept the syntax coef[j],
it works. I don't understand why. For me coef[j] is not correct because
it's a double ** and not type[][]. If someone could explain me that."

you were just winding us up. You already knew the answer, because you have
"nothing to learn in C".
Many of my friends will laugh if I say them than some give me the advice
to learn basic C.

There is much to laugh at.
 
W

William Hughes

Stop to say that, it's stupid. I have nothing to learn in C.

Piffle. You do not understand arrays for one.
Yeah I
not use the arrays, but they are useless.
So yes you could learn me
many things about them, but I don't care I don't use.

In which case you are entirely incompetent to maintain
code written by someone else. E.g. you do not understand
the very common idiom

func(int a[])

I do not use the shift operators, but I would not claim
that this means I can know C without knowing the shift
operators. In practice you have to know not only what they
are and how they should be used, but also how they
are used. I know that using a shift to multiply by a power
of two is a misplaced stab at efficiency (if your compiler
can't do this optimization, you have bigger problems than
a slower multiplication) but it is very common, and there
would be a lot of code I could not understand if I did not
recognize this.

You have a long way to go before you are a C expert.
Being able to write good C code is a necessary, but
not sufficient requirement.

- William Hughes
 
I

iesvs

You're just geeks guys. You think like geeks, talk like geeks and
understand nothing like geeks.
 
B

Barry Schwarz

No it's a char []

Ok, but it's a direct value, not an indirect value (p is an indirect
value). And I can use it like an indirect value. For me it's the same
thing than saying 0 = 1.

C doesn't use the terms direct value and indirect value. If you want
to use them, you must explain what they mean.
In the past I thought that a char[] was exactly a char * (the same
thing for the computer), so I find it correct to make f (a) where f
is ... f (char *) and a a char[]. But now no I saw that it's not the
same thing, and f (a) is incorrect for a mathematician (confuse a
direct value and an indirect what a silly idea).

Learn THE RULE: "Except when it is the operand of the sizeof operator
or the unary & operator, or is a string literal used to initialize an
array, an expression that has type ‘‘array of type’’ is converted to
an expression with type ‘‘pointer to type’’ that points to the initial
element of the array object and is not an lvalue."

What this tells you is that in most expressions, particularly as the
argument of a function, the array is converted to (evaluated as) a
pointer. Independent of whether the argument in the calling statement
is an array (f(a);) or pointer (f(p);), when f begins execution the
parameter is a pointer.

You seem convinced that C is full of silly ideas. Maybe you should
try another language that does things the way you want.


Remove del for email
 
I

iesvs

C doesn't use the terms direct value and indirect value. If you want
to use them, you must explain what they mean.

I know no language which hasn't direct and indirect value (it's not
Turing powerful without the indirect value).

An indirect value is something that you access by address.
A direct value is something that you access directly.

type * is indirect.
int, char, double, float etc are direct values.

C doesn't mention it but it use it, like any other language (Java has
indirect values, basic has indirect values, C++ also, OCaml also, Perl
also, JavaScrip also, Turing machine also, Lisp also etc.).
 
I

iesvs

Learn THE RULE: "Except when it is the operand of the sizeof operator
or the unary & operator, or is a string literal used to initialize an
array, an expression that has type ''array of type'' is converted to
an expression with type ''pointer to type'' that points to the initial
element of the array object and is not an lvalue."

What a ugly hack.
 
B

Ben Bacarisse

What a ugly hack.

There is always Haskell. Your programs might be a bit slower and I
would not try programming a wrist watch with it, but your programs
will be mathematically beautiful.

C is getting on a bit now, and the young do not always understand the
old. It serves its purpose well. If you don't understand its
purpose, it will seem peculiar -- like an old agricultural implement
you might find in a barn.
 
I

iesvs

I just express that I would find it better if a char[] was a char *,
for the developer, not for the computer.

And I don't use haskell I rather like OCaml (more efficient).
 
W

William Hughes

Stop to say that, it's stupid. I have nothing to learn in C.

Piffle. You know nothing about arrays.
Yeah I
not use the arrays, but they are useless. So yes you could learn me
many things about them, but I don't care I don't use.

So you are completely incompetent to maintain code that
you did not write. You would be stumped by the common idiom

func(int a[])


I do not use shift operators, but I do not consider that
it is possible to be an expert in C without understanding them.
Indeed, one
must know no only what they do, but how and why they are
commonly used. True, the use of a shift to multiply by a power
of two is usually a misplaced stab at efficiency (if your compiler
cannot
do this optimization you have bigger problems than a slow
multiplication) but if I did not know this was commonly done there
would be a lot of code that I could not understand
(e.g. Numerical Recipes).
Pointer rules,
that's all. Many of my friends will laugh if I say them than some give
me the advice to learn basic C.

Being able to generate good code is a necessary but not
sufficient condition for being an expert in C.

- William Hughes

PS: IMHO I am not an expert in C.
 
D

Default User

Stop to say that, it's stupid. I have nothing to learn in C. Yeah I
not use the arrays, but they are useless. So yes you could learn me
many things about them, but I don't care I don't use. Pointer rules,
that's all. Many of my friends will laugh if I say them than some give
me the advice to learn basic C.


You're either trolling, or incurably stupid. Either way, a waste of my
time.

*plonk*




Brian
 
T

Tor Rustad

"C is quirky, flawed and an enormous success"

These are not contradictory due to the "relatively" in the first
statement.[/QUOTE]


When talking about "relativity", I rather prefer the language of tensors
and statements put in covariant form.

;)
There are a few languages that are simpler and more logical than C,
and a whole lot that are the opposite.

Of the programming languages I know, C was the most difficult language
to master.

C may appear logical to a CS student, they never do much numerical
computations anyway, but for a FORTRAN programmer.. learning C was a pain.

Heck.. it took me years, to start counting at 0, avoid memory leaks,
wild pointers and other C pitfalls. I still remember my first Monte
Carlo simulation in C, what a disaster that was.
 
C

Charlie Gordon

Stop to say that, it's stupid. I have nothing to learn in C. Yeah I
not use the arrays, but they are useless. So yes you could learn me
many things about them, but I don't care I don't use. Pointer rules,
that's all. Many of my friends will laugh if I say them than some give
me the advice to learn basic C.

Are you Beavis or Butthead ?
 
C

Charlie Gordon

checkout the FAQs athttp://c-faq.com/, esp. Chapter 6

Very very strange.

//example
#include <stdio.h>
#include <stdlib.h>

void aff (int *a)
{
int i;
for (i = 0; i < 6; i++)
printf ("%d", a);
}

int main (void)
{
int a[6] = {1, 2, 3, 4, 5, 6};
aff (a);
return 0;
}

//end of example


Whether this code prints ``123456'' or nothing is implementation defined.
They said that "a" is a direct value but I can use it like it was an
indirect value. It's very strange. And nearly inconsistent. So it's
like gcc transform aff (a) by aff (&a). It's ugly. The arithmetic of
pointer is kicked with that. Not the classical arithmetic, the other
arithmetic (void is 0, void * is 1, void ** is 2 etc., there gcc make
-1 == 0, horrible for a mathematician, I know why I don't use array
now).

More likely because you know so little about C!
Your misconceptions are unfathomable, beyond repair.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top