[Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Pontless message:
----- Original Message -----
From: "Gaute B Strokkenes" <gs234@xxxxxxxxxxxxxxxx>
>
> Incidentally, this means that [] is abelian:
>
This is the first time I have seen the new words I learnt on my first
year maths (degree) course used anywhere else. Makes me feel special to
understand it...
> int
> main (int argc, char *argv[])
> {
> printf("The third letter of the alphabet is %c.\n", 2["ABC"]);
> }
Not sure if you're right though... I think some people are going odd on
the thing about pointer arithmetic/subscripts... given that an array
name and a pointer are the same thing, you get the same results,
excepting location in memory, with (excuse C++ code, point is the same
in C)
char* p = new char[50];
//initialise array
cout << p[20];
cout << *(p+20);
as you do with
char p[50];
//initialise array
cout << p[20];
cout << *(p+20);
and both should give unexpected results (or possibly errors) with
cout << p[-1];
as with
cout << *(p-1);
as well as with
cout << p[51];
and
cout << *(p+51);
Sory if someone else said this, or if I misunderstood... I'm a little
behind, a little out of practise, and a little tired...
SamBC
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, (continued)
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Dirk Stoecker, 2001/01/25
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Reinier Post, 2001/01/25
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Dirk Stoecker, 2001/01/26
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Reinier Post, 2001/01/26
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Gaute B Strokkenes, 2001/01/27
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Raimar Falke, 2001/01/27
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Gaute B Strokkenes, 2001/01/27
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Raimar Falke, 2001/01/27
- [Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Gaute B Strokkenes, 2001/01/27
[Freeciv-Dev] Re: (offtopic) C subscripts; was Re: Compiler-warnings, Gaute B Strokkenes, 2001/01/25
|
|