Store an array to an integer array??

R

rhitz1218

Hi all:

Is it possible to store an integer array to another integer array?
Or should I use an array of pointers that will point to a particular
array?

Thanks for the help.
 
B

Ben Pfaff

Is it possible to store an integer array to another integer array?

Do you mean an array of integer arrays? Just like this:
int x[2][3];
Or should I use an array of pointers that will point to a particular
array?

What are you trying to do?
 
R

rhitz1218

What are you trying to do?
--

For example, I have 4 integer arrays with size 4:

my_array1, my_array2, my_array3, my_array4..
each array will contain 4 integers..

Now I would like to store these 4 arrays in anothe location because I
would like to print them later on.. Can I store them in anothe array?
or should I create an array that points to them?


thanks..
 
S

santosh

Hi all:

Is it possible to store an integer array to another integer array?

If they're of the same type and size, then yes.
Or should I use an array of pointers that will point to a particular
array?

Can't say unless you tell us what you're trying to do. In programming
there're, usually, many ways to accomplish something. What is most
suitable depends on the details of the specific program and it's
environment.
 
S

santosh

For example, I have 4 integer arrays with size 4:

my_array1, my_array2, my_array3, my_array4..
each array will contain 4 integers..

Now I would like to store these 4 arrays in anothe location because I
would like to print them later on.. Can I store them in anothe array?
or should I create an array that points to them?

If your arrays are local and the code to print them will be elsewhere
in scope then you'll need to store these arrays somewhere else, just
pointing to them will not be enough.

If they're dynamically allocated or declared static or global then
holding pointers to them is sufficient.
 
R

rhitz1218

Can't say unless you tell us what you're trying to do. In programming
there're, usually, many ways to accomplish something. What is most
suitable depends on the details of the specific program and it's
environment.

I'm trying to find a "fixed point" of a number that is for ex:

954 (high to lo) - 495 (lo to high) = 495
then next step
954 (high to lo) - 495 (lo to high) = 495

from here, I can say that 495 is a fixed point, I would like to put
this in a "storage" (array??) so I can print all the fixed points that
I've found later..(Cause I need to check for other fixed points of
other numbers)

NOTE: 495 is stored in an array of size 3, I had to store each digits
in an array to perform my sorting..

thanks for the help..
 
S

santosh

I'm trying to find a "fixed point" of a number that is for ex:

954 (high to lo) - 495 (lo to high) = 495
then next step
954 (high to lo) - 495 (lo to high) = 495

from here, I can say that 495 is a fixed point, I would like to put
this in a "storage" (array??) so I can print all the fixed points that
I've found later..(Cause I need to check for other fixed points of
other numbers)

NOTE: 495 is stored in an array of size 3, I had to store each digits
in an array to perform my sorting..

See my reply to you in the other thread.
 
B

Barry Schwarz

Hi all:

Is it possible to store an integer array to another integer array?
Or should I use an array of pointers that will point to a particular
array?

You can always copy array elements using a loop with an assignment
statement as long as each from_element processed by the loop has be
assigned or initialized with a value.

If you are referring to one dimensional arrays, then memcpy will copy
data from one array to another as long as the number of bytes you
specify is not larger than the size of either array. This may or may
not be "better" than using a loop with an assignment statement.

If the arrays are multi-dimensional with identical dimensions, memcpy
will still work.

If the arrays are multi-dimensional with different dimensions, memcpy
can still be used but there may be some "boundary" issues.


Remove del for email
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top