Array copy - Increased size locally

S

srimks11

I have to copy an array "xyz" as passed in function arguments "void
Apple ( double xyz [MAX_NUM][CUT], W, X, Y, Z) to bigger size where
initially CUT = 3 but new increased size of CUT = 4.

CUT & MAX_NUM has been earlier defined in header file as -

---------
#define CUT 3

#define MAX_NUM 2048
---------

So, locally CUT should be modified of size 4 with MAX_NUM being same
as earlier, something as -

---
#include <stdio.h>

void Apple ( double xyz [MAX_NUM][CUT], W, X, Y, Z) {
.............
.............
......A....
.............
.............
}
---

Should I go for using normal FOR loop copy or memcpy() in section A
source code.

Please suggest.
 
B

Barry Schwarz

I have to copy an array "xyz" as passed in function arguments "void
Apple ( double xyz [MAX_NUM][CUT], W, X, Y, Z) to bigger size where
initially CUT = 3 but new increased size of CUT = 4.

CUT & MAX_NUM has been earlier defined in header file as -

There is no way for a function to change the value of a macro. Macro
substitution occurs prior to compilation and well before execution.
---
#include <stdio.h>

void Apple ( double xyz [MAX_NUM][CUT], W, X, Y, Z) {
............
............
.....A....
............
............
}

If you are going to change the size of the any dimension other than
the first, then you will have to have some kind of loop regardless.
xyz[0] consists of exactly CUT doubles, in this case 3. Your new
array will have 4 doubles. What value goes in the fourth?
Please suggest.

Create a 2 by 3 matrix as an example of the input to Apple and show us
exactly what the output should look like.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top