473,486 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Arrays

29 New Member
Hi I have a question from ab ook im trying to understand but can't get it. If someone can shoot me in the right direction i would appreciate it.

The question is:
Assume that ip has been declared to be a pointer to int and that result has been declared to be an array of 100 elements. Assume further that ip has been initialized to point to an element in the first half of the array.

Write an expression whose value is the element in the array after the element that ip points to.

My code is:
Expand|Select|Wrap|Line Numbers
  1. *ip[++&ip]
  2.  
Please help thanks
DRU
Oct 28 '06 #1
3 1256
arne
315 Recognized Expert Contributor
Hi I have a question from ab ook im trying to understand but can't get it. If someone can shoot me in the right direction i would appreciate it.

The question is:
Assume that ip has been declared to be a pointer to int and that result has been declared to be an array of 100 elements. Assume further that ip has been initialized to point to an element in the first half of the array.

Write an expression whose value is the element in the array after the element that ip points to.

My code is:
Expand|Select|Wrap|Line Numbers
  1. *ip[++&ip]
  2.  
Please help thanks
DRU

I thought the array is called 'result' ...?
You may try
Expand|Select|Wrap|Line Numbers
  1. *ip++;
  2.  
This should give the next value in the array after the value 'ip' points to.
Oct 28 '06 #2
Banfa
9,065 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. *ip++;
  2.  
That doesn't return the element in the array after the element that ip points to.

Because you have use post increment they value of the expression is the value of the element in the array that ip points to. Then once evaluated it increments ip to point to the next element.

Try any of these
Expand|Select|Wrap|Line Numbers
  1. *++ip;
  2.  
  3. *(ip+1);
  4.  
  5. ip[1];
Oct 28 '06 #3
arne
315 Recognized Expert Contributor
That doesn't return the element in the array after the element that ip points to.

Because you have use post increment they value of the expression is the value of the element in the array that ip points to. Then once evaluated it increments ip to point to the next element.

Try any of these
Expand|Select|Wrap|Line Numbers
  1. *++ip;
  2.  
  3. *(ip+1);
  4.  
  5. ip[1];
Oops, yes, you are right ...
Oct 28 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

19
2816
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type >...
21
3891
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
5
29227
by: JezB | last post by:
What's the easiest way to concatenate arrays ? For example, I want a list of files that match one of 3 search patterns, so I need something like DirectoryInfo ld = new DirectoryInfo(searchDir);...
3
2815
by: Michel Rouzic | last post by:
It's the first time I try using structs, and I'm getting confused with it and can't make it work properly I firstly define the structure by this : typedef struct { char *l1; int *l2; int Nval; }...
1
8683
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections...
41
4873
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
6
13129
by: Robert Bravery | last post by:
Hi all, Can some one show me how to achieve a cross product of arrays. So that if I had two arrays (could be any number) with three elements in each (once again could be any number) I would get:...
1
2431
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are...
16
2503
by: mike3 | last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms- windows.programmer.win32 since there's Windows material in here as well as questions related to standard C++. Not sure how that'd go over...
29
35375
weaknessforcats
by: weaknessforcats | last post by:
Arrays Revealed Introduction Arrays are the built-in containers of C and C++. This article assumes the reader has some experiece with arrays and array syntax but is not clear on a )exactly how...
0
7105
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
7180
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...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.