473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C Pointer problem

Hi,

I can't understand why this code causes a "memory read exception" at
int x=**a;

void pass(int** a)
{
int x=**a;
}
void main()
{
int arr[2][2]={{1,2},{3,4}};
pass(arr);
}
The assignment of int int x=**a in the main function works.

Tanks for your help,
Markus

May 31 '06
73 3739
>> Someone tell me, does one learn PODMAS instead of BODMAS in the USA?


I actually learned BOMDAS at school, rather than "BODMAS".

Brackets
Off
Multiply
Divide
Add
Substract


Parentheses count. I always thought that math as well as FORTRAN
and C taught BO(MD)(AS), *not* BODMAS nor BOMDAS, unless division
was represented textually as a big horizontal bar with the denominator
being clearly distinguished by what was under the bar. But I was
educated on the USA side of the pond.

Gordon L. Burditt

--
This newsgroup is comp.lang.c . Please post articles consisting
entirely of discussion about attributions, top-posting, Google,
topicality, Web TV, bottom-posting, forgeries, netiquette, trolls,
and cross-posting to cop.lang.c, not comp.lang.c .
Jun 28 '06 #51
Mark McIntyre wrote:
On Mon, 26 Jun 2006 02:30:03 GMT, in comp.lang.c , pete
<pf*****@mindspring.com> wrote:

The example shown had empty parentheses and empty braces
and he was saying something that you suggest was false
about empty brackets.


It was, obviously, contained within the brackets. -)
So where's my clue as to what he's talking about?


Two nations divided by a common language indeed.

For the record, brackets come in three flavours, square, wiggly and
plain.


4. angle <>

goose

Jun 28 '06 #52
goose wrote:

Mark McIntyre wrote:
On Mon, 26 Jun 2006 02:30:03 GMT, in comp.lang.c , pete
<pf*****@mindspring.com> wrote:

The example shown had empty parentheses and empty braces
and he was saying something that you suggest was false
about empty brackets.


It was, obviously, contained within the brackets. -)
So where's my clue as to what he's talking about?


Two nations divided by a common language indeed.

For the record, brackets come in three flavours, square, wiggly and
plain.


4. angle <>


The standard doesn't give a name for <>,
but I also call them angle brackets.

I will always advocate using standard terminology,
when discussing what the C standard says.

--
pete
Jun 28 '06 #53
In article <11*********************@75g2000cwc.googlegroups.c om>,
goose <ru**@webmail.co.za> wrote:
Mark McIntyre wrote:
For the record, brackets come in three flavours, square, wiggly and
plain.

4. angle <>


I understand that in at least some parts of Europe (e.g., France), there
is also <<>> where << and >> are the closest easy representation
to single characters smaller and raised to be centred on the line.
I have, though, not encountered this enough to be sure whether they
are used as brackets or only as a form of quotation -- I -think- I've
seen both uses.
--
"law -- it's a commodity"
-- Andrew Ryan (The Globe and Mail, 2005/11/26)
Jun 28 '06 #54
Walter Roberson wrote:

I understand that in at least some parts of Europe (e.g., France),
there is also <<>> where << and >> are the closest easy representation
to single characters smaller and raised to be centred on the line.


http://en.wikipedia.org/wiki/Guillemet


Brian
Jun 28 '06 #55
Mark McIntyre <ma**********@spamcop.net> writes:
[...]
Two nations divided by a common language indeed.

For the record, brackets come in three flavours, square, wiggly and
plain.

gd&r


Does British English not commonly use the terms "parentheses" and
"braces"?

I understand that "braces" refers to the clothing accessory that
Americans refer to as "suspenders", but there seems to be little
chance of confusion.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jun 28 '06 #56
Keith Thompson wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
[...]
Two nations divided by a common language indeed.

For the record, brackets come in three flavours, square, wiggly and
plain.

gd&r

Does British English not commonly use the terms "parentheses" and
"braces"?

Not in normal speech, "brackets" and "curly brackets" would be more common.
I understand that "braces" refers to the clothing accessory that
Americans refer to as "suspenders", but there seems to be little
chance of confusion.

"suspenders" hold up women's stockings, so talk of a man in suspenders
can cause all sorts of confusion!

The joys of a common language..

--
Ian Collins.
Jun 28 '06 #57
Keith Thompson wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
[...]
Two nations divided by a common language indeed.

For the record, brackets come in three flavours, square, wiggly and
plain.

gd&r
Does British English not commonly use the terms "parentheses" and
"braces"?


Parentheses was used in my maths class as school in Britain oh so many
years ago and we were told that it, and not brackets, was the correct
term for (). However, it was certainly common back then for people to
describe () as brackets.

So I, born and brought up in England, am happy with the terms
parenthesis (), brackets [] and braces {} but can also accept and cope
with round brackets, square brackets and squiggly brackets. I'll also
accept brackets for () without comment if the context removes any ambiguity.
I understand that "braces" refers to the clothing accessory that
Americans refer to as "suspenders", but there seems to be little
chance of confusion.


Yes, this is also true. Assuming, of course, that Americans common call
braces suspenders. However, you should possibly be aware that in Britain
suspenders are used by ladies to hold their stockings up, so be careful
what you ask for in a clothing store in Britain ;-)
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Jun 28 '06 #58
Tom St Denis wrote:
Frederick Gotham wrote:
Should I wait for you to re-post acknowledging your mistake, or should I
post the solution now?
If we multiply first, we get:

4*12 divided by 3*8
But that isn't what you wrote. You wrote 4*12/3*8.
which becomes:

48 divided by 24


No that becomes 4*4*8.


Which part of "if we multiply first" escaped you?
Not only does logic dictate that


Logic doesn't have a say in it. Operator precedence is about convenient
convention.

--
Chris "logic is a good servant but a bad master" Dollin
"Life is full of mysteries. Consider this one of them." Sinclair, /Babylon 5/

Jun 29 '06 #59
Ian Collins <ia******@hotmail.com> wrote:
Keith Thompson wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
Two nations divided by a common language indeed.

For the record, brackets come in three flavours, square, wiggly and
plain.


Does British English not commonly use the terms "parentheses" and
"braces"?

Not in normal speech, "brackets" and "curly brackets" would be more common.


Probably because strictly speaking the parenthesis is the phrase
inserted into the surrounding sentence, nor either of the marks
delimiting it.
I understand that "braces" refers to the clothing accessory that
Americans refer to as "suspenders", but there seems to be little
chance of confusion.

"suspenders" hold up women's stockings, so talk of a man in suspenders
can cause all sorts of confusion!


Unless, of course, said man wants to be a lumberjack.

Richard
Jun 29 '06 #60
Flash Gordon wrote:
Keith Thompson wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
[...]
Two nations divided by a common language indeed.
For the record, brackets come in three flavours, square, wiggly and
plain.
gd&r


Does British English not commonly use the terms "parentheses" and
"braces"?


Parentheses was used in my maths class as school in Britain oh so many
years ago and we were told that it, and not brackets, was the correct
term for (). However, it was certainly common back then for people to
describe () as brackets.

So I, born and brought up in England, am happy with the terms
parenthesis (), brackets [] and braces {} but can also accept and cope
with round brackets, square brackets and squiggly brackets. I'll also
accept brackets for () without comment if the context removes any
ambiguity.
I understand that "braces" refers to the clothing accessory that
Americans refer to as "suspenders", but there seems to be little
chance of confusion.


Yes, this is also true. Assuming, of course, that Americans common call
braces suspenders. However, you should possibly be aware that in Britain
suspenders are used by ladies to hold their stockings up, so be careful
what you ask for in a clothing store in Britain ;-)


Ah the innocence of youth. English suspenders are American garters. My
grandfather wore garters to hold his socks up.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Jun 29 '06 #61
On Tue, 27 Jun 2006 22:03:29 GMT, in comp.lang.c , Frederick Gotham
<fg*******@SPAM.com> wrote:
Should I wait for you to re-post acknowledging your mistake,
T'would be tricky to do that, since there isn't one.
If we multiply first,


Oh, you mean solutions that break the rules of maths. I see, I thought
you meant actual solutions. If we're going to allow fantasy maths,
then I really must introduce you to my fascinating proof that 1==2

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 29 '06 #62
On Thu, 29 Jun 2006 09:16:04 +0100, in comp.lang.c , Chris Dollin
<ch**********@hp.com> wrote:
Which part of "if we multiply first" escaped you?


The part where the original expression contained some prior
multiplication.

"Dad, if I take three people and three more people, and divide the
group in two, how many people do I have?"

"None".

"how so?"

"if you divide them first, you have six dead people".
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 29 '06 #63
Mark McIntyre wrote:
On Tue, 27 Jun 2006 22:03:29 GMT, in comp.lang.c , Frederick Gotham
<fg*******@SPAM.com> wrote:
Should I wait for you to re-post acknowledging your mistake,


T'would be tricky to do that, since there isn't one.
If we multiply first,


Oh, you mean solutions that break the rules of maths. I see, I thought
you meant actual solutions. If we're going to allow fantasy maths,
then I really must introduce you to my fascinating proof that 1==2


Would that be this one
<http://www.math.toronto.edu/mathnet/falseProofs/first1eq2.html> or
this one
<http://www.math.toronto.edu/mathnet/falseProofs/second1eq2.html>?

Robert Gamble

Jun 29 '06 #64
Mark McIntyre <ma**********@spamcop.net> writes:
On Tue, 27 Jun 2006 22:03:29 GMT, in comp.lang.c , Frederick Gotham
<fg*******@SPAM.com> wrote:
Should I wait for you to re-post acknowledging your mistake,


T'would be tricky to do that, since there isn't one.
If we multiply first,


Oh, you mean solutions that break the rules of maths. I see, I thought
you meant actual solutions. If we're going to allow fantasy maths,
then I really must introduce you to my fascinating proof that 1==2


The rule that multiplication and division have the same precedence is
a rule of mathematical *notation*, not a fundamental rule of
mathematics.

Different languages have different notational rules. In both C and
the brand of ordinary arithmetic notation that you and I both learned,
multiplication and division happen to have the same precedence. In
APL, if I recall correctly, there are no precedence levels; everything
is evaluated right-to-left (if that's not the actual rule for APL,
it's at least a possible consistent one). Lisp specifies everything
with parentheses. And so Forth.

A notation in which multiplication and division have different
precedence levels could be perfectly internally consistent.

Whether such a notation is actually in use anywhere is another
question (and not a particularly topical one), but there should be no
difficulty imagining how such a system would work.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jun 29 '06 #65
Richard Bos wrote:
Ian Collins <ia******@hotmail.com> wrote:
Keith Thompson wrote:
I understand that "braces" refers to the clothing accessory that
Americans refer to as "suspenders", but there seems to be little
chance of confusion.

"suspenders" hold up women's stockings, so talk of a man in suspenders
can cause all sorts of confusion!


Unless, of course, said man wants to be a lumberjack.


And that's OK.

--
Simon.
Jun 29 '06 #66
Mark McIntyre wrote:
On Thu, 29 Jun 2006 09:16:04 +0100, in comp.lang.c , Chris Dollin
<ch**********@hp.com> wrote:
Which part of "if we multiply first" escaped you?
The part where the original expression contained some prior
multiplication.


The expression had the form `a * b / c * d`. Since this isn't
fully bracketed, some convention must be adopted for deciding
which operands belong to which operators. This convention is
just that - a /convention/. For rantable reasons, this convention
is often expressed in terms of "what operators get done first",
with an operational procedure of "find the next operator to be
done and evaluate it with the nearest (shortest) operands".
Fortunately, mathematical expressions don't have (side-)effects,
so all this does is set people up for glorious errors when they
encounter imperative programming languages.

"If we multiply first" is a way of expressing a precedence
relation. No "prior multiplication" is involved.
"Dad, if I take three people and three more people, and divide the
group in two, how many people do I have?"

"None".

"how so?"

"if you divide them first, you have six dead people".


An excellent illustration of how choosing different precedence
rules will get you different answers, although "divide the
group into two" applies excessive disambiguation pressure.

--
Chris "sever the corpus callosum, however ..." Dollin
"Who do you serve, and who do you trust?" /Crusade/

Jun 30 '06 #67
Ian Collins wrote:
Keith Thompson wrote:


<snipped>
I understand that "braces" refers to the clothing accessory that
Americans refer to as "suspenders", but there seems to be little
chance of confusion.

"suspenders" hold up women's stockings, so talk of a man in suspenders
can cause all sorts of confusion!

The joys of a common language..


you meant C, right?

goose,
'cos english aint/isn't what it used to be :-)

Jun 30 '06 #68
On Fri, 30 Jun 2006 09:26:46 +0100, in comp.lang.c , Chris Dollin
<ch**********@hp.com> wrote:
The expression had the form `a * b / c * d`. Since this isn't
fully bracketed, some convention must be adopted for deciding
which operands belong to which operators.
Agreed. The point is however, conventions are just that, agreed by
convention. One can say "the answer is x not Y because I don't follow
conventions" but one can't then expect to be treated seriously.
"Dad, if I take three people and three more people, and divide the
group in two, how many people do I have?"

"None".

"how so?"

"if you divide them first, you have six dead people".


An excellent illustration of how choosing different precedence
rules will get you different answers,


Actually, I thought it was an excellent example of why ignoring
convention will give you absurd answers.
although "divide the
group into two" applies excessive disambiguation pressure.


Carefully worded :-)
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 30 '06 #69
On 29 Jun 2006 14:59:18 -0700, in comp.lang.c , "Robert Gamble"
<rg*******@gmail.com> wrote:
Mark McIntyre wrote:
On Tue, 27 Jun 2006 22:03:29 GMT, in comp.lang.c , Frederick Gotham
<fg*******@SPAM.com> wrote:
>Should I wait for you to re-post acknowledging your mistake,


T'would be tricky to do that, since there isn't one.
>If we multiply first,


Oh, you mean solutions that break the rules of maths. I see, I thought
you meant actual solutions. If we're going to allow fantasy maths,
then I really must introduce you to my fascinating proof that 1==2


Would that be this one
<http://www.math.toronto.edu/mathnet/falseProofs/first1eq2.html> or
this one
<http://www.math.toronto.edu/mathnet/falseProofs/second1eq2.html>?


The first has the beauty of simplicity, but the second is more subtle
since it uses a 'common sense' rule to introduce the fallacy.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 30 '06 #70
On Thu, 29 Jun 2006 22:49:43 GMT, in comp.lang.c , Keith Thompson
<ks***@mib.org> wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
On Tue, 27 Jun 2006 22:03:29 GMT, in comp.lang.c , Frederick Gotham
<fg*******@SPAM.com> wrote:
Should I wait for you to re-post acknowledging your mistake,


T'would be tricky to do that, since there isn't one.
If we multiply first,


Oh, you mean solutions that break the rules of maths. I see, I thought
you meant actual solutions. If we're going to allow fantasy maths,
then I really must introduce you to my fascinating proof that 1==2


The rule that multiplication and division have the same precedence is
a rule of mathematical *notation*, not a fundamental rule of
mathematics.


I agree. How does this contradict what I said?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 30 '06 #71
Mark McIntyre <ma**********@spamcop.net> writes:
On Thu, 29 Jun 2006 22:49:43 GMT, in comp.lang.c , Keith Thompson
<ks***@mib.org> wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
On Tue, 27 Jun 2006 22:03:29 GMT, in comp.lang.c , Frederick Gotham
<fg*******@SPAM.com> wrote:
Should I wait for you to re-post acknowledging your mistake,

T'would be tricky to do that, since there isn't one.

If we multiply first,

Oh, you mean solutions that break the rules of maths. I see, I thought
you meant actual solutions. If we're going to allow fantasy maths,
then I really must introduce you to my fascinating proof that 1==2


The rule that multiplication and division have the same precedence is
a rule of mathematical *notation*, not a fundamental rule of
mathematics.


I agree. How does this contradict what I said?


Since you ask, you referred to "solutions that break the rules of
maths". I distinguish between rules of mathematics (such as how
addition and multiplication work) and notational conventions. A proof
that 1 == 2 violates the former; an interpretation of 4 * 12 / 3 * 8
other than the usual one merely violates the latter.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jun 30 '06 #72
On Fri, 30 Jun 2006 21:00:44 GMT, in comp.lang.c , Keith Thompson
<ks***@mib.orgwrote:
>I distinguish between rules of mathematics (such as how
addition and multiplication work) and notational conventions.
FCOL. Its not a "notational convention" and even if it were, you can't
simply discard it. Otherwise why bother at all.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 2 '06 #73
On Mon, 26 Jun 2006 02:30:03 GMT, pete <pf*****@mindspring.comwrote:
Dave Thompson wrote:
<snip>
[The PP] obviously meant brackets in the en_GB (or UK?)
meaning, what en_US (and the standard) calls parentheses.

The example shown had empty parentheses and empty braces
and he was saying something that you suggest was false
about empty brackets.
So where's my clue as to what he's talking about?
His statement, to which I responded, was about the difference
between an old-style function definition
int foo () { body }
which specifies no parameters, and a declaration-only
int foo () ;
which does not specify parameters/signature.

He claimed the former is equivalent to (void) (a prototype)
and I quoted and responded specifically to that point,
with cites that were specifically about function declarators,
parameter-type lists and identifier lists, all of which in the
standard grammar involve rounds and not curlies.

Those seem like enough clues to me.

- David.Thompson1 at worldnet.att.net
Jul 10 '06 #74

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Carsten Spieß | last post by:
Hello all, i have a problem with a template constructor I reduced my code to the following (compiled with gcc 2.7.2) to show my problem: // a base class class Base{}; // two derived...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
7
by: Mike D. | last post by:
I have a problem with a dynamic library I am developing, but it is really more of a pointer issue than anything else. Hopefully someone here can lend me some assistance or insight into resolving...
10
by: Kieran Simkin | last post by:
Hi, I wonder if anyone can help me, I've been headscratching for a few hours over this. Basically, I've defined a struct called cache_object: struct cache_object { char hostname; char ipaddr;...
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
7
by: Marcelo | last post by:
Hi everybody, I don't understand why I am having a problem in this code. The problem is that my pointer *phist in main method, it is declared. Then I send the pointer to my method, and this...
51
by: Joe Van Dyk | last post by:
When you delete a pointer, you should set it to NULL, right? Joe
2
by: toton | last post by:
Hi, This is continuation of topic pointer & reference doubt. http://groups.google.com/group/comp.lang.c++/browse_thread/thread/df84ce6b9af561f9/76304d7d77f6ccca?lnk=raot#76304d7d77f6ccca But I...
9
by: junky_fellow | last post by:
Hi, To print the pointer using printf(), we convert it to (void *) . printf("%p",(void *)ptr); My question is how printf() determine which type of pointer is passed to it and prints its value...
6
by: worlman385 | last post by:
For pointer and non-pointer initialization of an object like MyCar mycar; MyCar* mycar = new MyCar(); I heard from other people saying if object i create must live outside scape, then I use...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.