473,554 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

initializing array using pointer

suppose i have a pointer to an array of integers.can i initialize each
member of the array using pointers?plz explain

Dec 13 '05 #1
31 2207
Hi,

You can assign values to array elements using pointer. Look at the code
below:

main ()
{
int array[3];
int *pArry, count;

pArry = array;

*pArry = 1; pArry++;
*pArry =2; pArry++;
*pArry =3;

for (count = 0; count <3; count++)
printf ("array[%d] contains %d\r\n",count, array[count]);

}

Is this what you want.

Regards,
Saurabh.

arun wrote:
suppose i have a pointer to an array of integers.can i initialize each
member of the array using pointers?plz explain


Dec 13 '05 #2
arun wrote:
suppose i have a pointer to an array of integers.can i initialize each
member of the array using pointers?plz explain


You mean something like:

#define ARR_MAX 100

int arr[ARR_MAX];
int *myptr;
int i;

myptr = arr;
for(i=0; i<ARR_MAX; i++) {
*myptr = 0;
myptr++;
}

Dec 13 '05 #3
Question not clear.

Dec 13 '05 #4
Johny <in********@gma il.com> wrote:
Question not clear.


Neither was your response:

It is proper Usenet etiquette to include the relevant portions of the text
you are replying to. To do this using Google groups, please follow the
instructions below, penned by Keith Thompson:

If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Dec 13 '05 #5
In article <dn**********@c hessie.cirr.com >,
Christopher Benson-Manica <at***@nospam.c yberspace.org> wrote:
Johny <in********@gma il.com> wrote:
Question not clear.


Neither was your response:

It is proper Usenet etiquette to include the relevant portions of the text
you are replying to. To do this using Google groups, please follow the
instructions below, penned by Keith Thompson:

If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.


You (and others, such as Keith) are wasting your breath. They'll never get
it. And I'll tell you why.

Imagine that there's a mouse - and the mouse is the Usenet. You and I can
see that it is a mouse and we behave accordingly. But now there is a class
of users (we'll call them "googlers") that are wearing these funny weird
glasses that make them see not a mouse, but an elephant. Seeing an
elephant (i.e., the Usenet as a web page), they also behave accordingly.
And no amount of verbiage from us is going to convince them that it's not
an elephant - that it is only a mouse.

To make this more clear, to a googler, it doesn't make any sense to "quote"
(whatever the heck that is...), in fact, to do so would be absurd, when all
the rest of the articles in the thread are right there in front of their
faces (just as clear as the trunk on that mouse, er, elephant). And no
amount of verbiage from us is going to convince them not to believe what
they see. The point is you can *never* convince someone that what they see
isn't reality. The only way you can address the problem is to help them
fix their eyesight (or help them remove their funny glasses).

Dec 13 '05 #6
ga*****@yin.int eraccess.com (Kenny McCormack) wrote:
In article <dn**********@c hessie.cirr.com >,
Christopher Benson-Manica <at***@nospam.c yberspace.org> wrote:
Johny <in********@gma il.com> wrote:
Question not clear.


Neither was your response:

It is proper Usenet etiquette to include the relevant portions of the text
you are replying to. To do this using Google groups, please follow the
instructions below, penned by Keith Thompson:

If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.


You (and others, such as Keith) are wasting your breath. They'll never get it.


Neither will you, but if we stop trying your kind will have won and all
will be barbarity.

Richard
Dec 13 '05 #7
In article <43************ ****@news.xs4al l.nl>,
Richard Bos <rl*@hoekstra-uitgeverij.nl> wrote:
ga*****@yin.in teraccess.com (Kenny McCormack) wrote:
In article <dn**********@c hessie.cirr.com >,
Christopher Benson-Manica <at***@nospam.c yberspace.org> wrote:
>Johny <in********@gma il.com> wrote:
>
>> Question not clear.
>
>Neither was your response:
>
>It is proper Usenet etiquette to include the relevant portions of the
>text you are replying to. To do this using Google groups, please
>follow the instructions below, penned by Keith Thompson:
>
>If you want to post a followup via groups.google.c om, don't use
>the broken "Reply" link at the bottom of the article. Click on
>"show options" at the top of the article, then click on the
>"Reply" at the bottom of the article headers.


You (and others, such as Keith) are wasting your breath. They'll never
get it.


Neither will you, but if we stop trying your kind will have won and all
will be barbarity.

Richard


To borrow a line from a fellow troll:

You say that like it would be a Bad Thing.

Dec 13 '05 #8
Richard Bos wrote:
ga*****@yin.int eraccess.com (Kenny McCormack) wrote:
In article <dn**********@c hessie.cirr.com >,
Christopher Benson-Manica <at***@nospam.c yberspace.org> wrote:
Johny <in********@gma il.com> wrote:

Question not clear.
Neither was your response:

It is proper Usenet etiquette to include the relevant portions of the text
you are replying to. To do this using Google groups, please follow the
instructions below, penned by Keith Thompson:

If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.

You (and others, such as Keith) are wasting your breath. They'll never get it.


Neither will you, but if we stop trying your kind will have won and all
will be barbarity.

You already stopped trying. Please, DFTT, no matter what. Every reply is a loss.

S.
Dec 13 '05 #9
Richard Bos wrote:
ga*****@yin.int eraccess.com (Kenny McCormack) wrote:

[google reply]
You (and others, such as Keith) are wasting your breath. They'll
never get it.


Neither will you, but if we stop trying your kind will have won and
all will be barbarity.


And of course, Kenny is wrong (what a surprise). Many of the people
have learned to quote properly via the instructions given to them.
Many, if not most, do so because the Google interface is so archane
that they couldn't figure out how to do so.

With any luck the idjits at Google will switch that around.
Brian

Dec 13 '05 #10

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

Similar topics

7
2409
by: masood.iqbal | last post by:
I am having lots of trouble getting a simple program that initializs a dynamically allocated 2D array to work. My 2D array is not getting initialized properly, and additionally I am getting a "Null pointer assignment" error. Kindly help. Also, eventually I intend to move this logic to a separate function. For that, I believe, that I will...
5
10558
by: pmatos | last post by:
Hi all, I have a vector of vector of ints, I could use C approach by using int but I think C++ vector<vector<int> > would be easier to manage. So I have a function which creates and initializes the vector with the values I need (I know these values before hand). - What's the best way to initialize the vector<vector<int> >? Can I...
13
27022
by: simondex | last post by:
Hi, Everyone! Does anyone know how to initialize an int array with a non-zero number? Thank You Very Much. Truly Yours, Simon Dexter
10
4754
by: Bart Goeman | last post by:
Hi, I have a question about how to put redundant information in data structures, initialized at compile time. This is often necessary for performance reasons and can't be done at run time (data structures are read only) Ideally one should be able to put the redundant information there automatically so no mistakes are possible, but in a...
21
3080
by: rupesh_533 | last post by:
I am assuming the following things. 1.Pointer to an integer means it points to an integer,On incrementing the pointer,it points to the next integer in memory. 2.Pointer to an array of some size means it points to an array,On incrementing the pointer,it should point to next array of that size. Correct me if i am wrong. We declare a pointer...
7
2089
by: Paminu | last post by:
In the following code I am trying to initialize a pointer that is located in a struct. #include <stdlib.h> #include <stdio.h> #define KIDS 4 typedef struct test { void *content;
11
2278
by: sg71.cherub | last post by:
Hi All, I have encapsulate CvMat of OpenCV into my own matrix class as the following: class CVMatrix { //== Fields private: unsigned m_Width;
13
2315
by: WaterWalk | last post by:
Hello. When I consult the ISO C++ standard, I notice that in paragraph 3.6.2.1, the standard states: "Objects with static storage duration shall be zero-initialized before any other initialization takes place." Does this mean all non-local objects will be zero-initialized before they are initialized by their initializers(if they have)? For...
3
2801
by: Ramesh | last post by:
Hi, I am trying to create an array of pointers to member functions inside my class. When I created a global array of type pfn & initialized with member functions and copy it back to the member function pointer array (Handlers) - compiler doesnt let me do that. I got an error as below: "invalid use of non-static member function bool...
0
7535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7574
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7894
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5442
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3579
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3561
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2026
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 we have to send another system
1
1145
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
850
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.