473,387 Members | 1,897 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,387 software developers and data experts.

What does it mean int (*a)[10]

What does it mean:

int (*a)[10];
Jul 22 '05 #1
16 4653

"Quick Function" <qu******@yahoo.com> wrote in message
news:21**************************@posting.google.c om...
What does it mean:

int (*a)[10];


a is a pointer to an array of 10 ints. So, for example, a++ will increase a
by the size of 10 ints (40 bytes on most platforms, but I can't speak for
yours).
Jul 22 '05 #2
Quick Function wrote in
news:21**************************@posting.google.c om in comp.lang.c++:
What does it mean:

int (*a)[10];


'a' points to an array of 10 intergers:

#include <iostream>

int main()
{
int array[ 10 ];
int (*a)[10] = &array;

for ( int i = 0; i < 10; ++i ) (*a)[i] = i;

for ( int i = 0; i < 10; ++i ) std::cerr << array[i] << '\n';
}

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #3

int (*a)[10];


'a' points to an array of 10 intergers:


At least eleven? [0...10]
Jul 22 '05 #4
"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...

int (*a)[10];


'a' points to an array of 10 intergers:


At least eleven? [0...10]


Nope. 0..9
Jul 22 '05 #5
>
for ( int i = 0; i < 10; ++i ) std::cerr << array[i] << '\n';
}

Rob.

sorry, it isn't on topic;
what is difference between cerr and cout ??
thanks,
Jul 22 '05 #6
In message <x_****************@newssvr29.news.prodigy.com>, Mabden
<mabden@sbc_global.net> writes
"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...

> > int (*a)[10];
> >
>
> 'a' points to an array of 10 intergers:


At least eleven? [0...10]


Nope. 0..9

10.5 : you can point at [10] but not access it.

;-)

--
Richard Herring
Jul 22 '05 #7
pvsp wrote:

for ( int i = 0; i < 10; ++i ) std::cerr << array[i] << '\n';
}

Rob.

sorry, it isn't on topic;
what is difference between cerr and cout ??
thanks,


cerr is the error output stream
cout is the output stream

On some operating systems it is possible to redirect
output to eg a file. This is handy because then
the program by itself doesn't need to deal with files, but
yet can be used to produce a file (by redirecting
its output into a file). But then it is also possible
to redirect the error stream into a different file, such
that you can easily seperate the real output from the
error messages in different files.

cout is also usually buffered while cerr is not.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #8
pvsp wrote in news:11**************************@posting.google.c om in
comp.lang.c++:

for ( int i = 0; i < 10; ++i ) std::cerr << array[i] << '\n';
}

Rob.

sorry, it isn't on topic;
what is difference between cerr and cout ??
thanks,


They are different streams which on most systems go to the same place,
i.e. the "console".

However std::cerr, differs from std::cout in that every time a '\n' char
is sent to it, it calls flush(), so the output should be immediatly
visible (or writen to the file if its been redirected).

For std::cout you need to call flush() (std::cout.flush()) or
alternativly use std::endl (std::cout << std::endl) which sends
a '\n' char and then calls flush() all by itself.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #9

"Richard Herring" <ju**@[127.0.0.1]> schrieb im Newsbeitrag
news:rA**************@baesystems.com...
In message <x_****************@newssvr29.news.prodigy.com>, Mabden
<mabden@sbc_global.net> writes
"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...


> > int (*a)[10];
> >
>
> 'a' points to an array of 10 intergers:

At least eleven? [0...10]


Nope. 0..9

10.5 : you can point at [10] but not access it.


In a release version you can even access it. I'd suggest read asscess
only ;)

Jul 22 '05 #10
Gernot Frisch wrote:

"Richard Herring" <ju**@[127.0.0.1]> schrieb im Newsbeitrag
news:rA**************@baesystems.com...
In message <x_****************@newssvr29.news.prodigy.com>, Mabden
<mabden@sbc_global.net> writes
"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...
>
>
> > > int (*a)[10];
> > >
> >
> > 'a' points to an array of 10 intergers:
>
> At least eleven? [0...10]

Nope. 0..9
10.5 : you can point at [10] but not access it.


In a release version you can even access it.


You can, but it is undefined behaviour. Just the same
as you would access [11], [12], [13], [14], etc ...
I'd suggest read asscess
only ;)

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #11
> > In a release version you can even access it.

You can, but it is undefined behaviour. Just the same
as you would access [11], [12], [13], [14], etc ...


That's why I'd only try reading - it if at all... :))
Jul 22 '05 #12
Gernot Frisch wrote:
In a release version you can even access it.


You can, but it is undefined behaviour. Just the same
as you would access [11], [12], [13], [14], etc ...


That's why I'd only try reading - it if at all... :))


No 'if at all'.
Even reading is illegal :-)

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #13
Gernot Frisch wrote in news:2n************@uni-berlin.de in comp.lang.c++:
> In a release version you can even access it.


You can, but it is undefined behaviour. Just the same
as you would access [11], [12], [13], [14], etc ...


That's why I'd only try reading - it if at all... :))


Reading is accessing, reading is UB, don't read (aka access) an object
beyond the end of an array (or any other container for that matter).

If your compiler lets you "Get Away With It(tm)" today it may not
tomorrow, its UB anything can, and by Murphy's Law will, happen.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #14
In message <2n************@uni-berlin.de>, Gernot Frisch
<Me@Privacy.net> writes
> In a release version you can even access it.


You can, but it is undefined behaviour. Just the same
as you would access [11], [12], [13], [14], etc ...


That's why I'd only try reading - it if at all... :))

Reading is still access and therefore UB.
--
Richard Herring
Jul 22 '05 #15

"Rob Williscroft" <rt*@freenet.co.uk> wrote in message
However std::cerr, differs from std::cout in that every time a '\n' char
is sent to it, it calls flush(), so the output should be immediatly
visible (or writen to the file if its been redirected).,


Actually, cerr has unitbuf set. Every output operation is flushed.
There is no "linebuffering" mode defined in C++ although some
non-unibuf stream implementations work that way on terminals.

Jul 22 '05 #16
Ron Natalie wrote in news:41**********************@news.newshosting.com
in comp.lang.c++:

"Rob Williscroft" <rt*@freenet.co.uk> wrote in message
However std::cerr, differs from std::cout in that every time a '\n'
char is sent to it, it calls flush(), so the output should be
immediatly visible (or writen to the file if its been redirected).,


Actually, cerr has unitbuf set. Every output operation is flushed.
There is no "linebuffering" mode defined in C++ although some
non-unibuf stream implementations work that way on terminals.


Thanks, this is a detail I should have remembered, its been said here
enough times :).

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #17

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

Similar topics

4
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
6
by: WindAndWaves | last post by:
Hi Folks I have inhereted a script that I understand reasonably well, I just do not understand !/^\d+$/.test(el.value) what the hell does that mean? Below is the script (there are really...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
35
by: wilsonidv | last post by:
Daer All: I have studied C language for just 2~3 months. I'd like to know the critical parts of C, focusing on these. Could anyone has many experiences tell me, please. Thanks and Regards.
13
by: Protoman | last post by:
I'm getting an error: 10 C:\Dev-Cpp\Enigma.cpp no match for 'operator<' in 'i < (+cleartext)->std::basic_string<_CharT, _Traits, _Alloc>::end ()' Code: Enigma.hpp...
4
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader =...
9
by: JoeC | last post by:
m_iWidth = (int)pBitmapInfo->bmiHeader.biWidth; m_iHeight = (int)pBitmapInfo->bmiHeader.biHeight; What does this mean? I have seen v=&var->member.thing; but what does it mean when you...
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.