question about pointer and array.
can we add a 2-D array (**A) with a 1-D array (*B)? both of the array is define as a pointer in the program.
where array A is A[j] and B is B
new in C programming and pointer is difficult.... :-|
question about pointer and array.
can we add a 2-D array (**A) with a 1-D array (*B)? both of the array is define as a pointer in the program.
where array A is A[j] and B is B
new in C programming and pointer is difficult.... :-|
Um... yes. But not with the + operator, of course; with some specially built procedure. I don't know what you mean by 'add', either, but surely there's some way for you to write the algorithm.
the solution i need to obtain is
sum = A[j] + B;
couldn't add 2-d array and 1-d array using + or using IMSL libraries. is it cause of A is a 2-D array? is that mean that sum and B have to be 2-D array?
i'm try to use this method (something similiar), where *B will become **B,
void pointTo(char **src, char *dst);
int main() {
/* local variables */
char text[3];
char *ptr;
/* point our pointer to our local variable */
pointTo(&ptr, text);
/* modify pointer data; affects local data due to pointer linkage */
ptr[0] = 'A';
ptr[1] = '\0';
/* end program */
return 0;
}
void pointTo(char **src, char *dst) {
*src = dst;
}
>the solution i need to obtain is
>sum = A[j] + B;
What are the types of A, B, and sum? I really don't see what the problem is unless A[j] and B are incompatible for addition, or sum can't hold a value of the result.
the solution i need to obtain is
sum[i] = A[i][j] + B[i];
What are the types of A, B, and sum? I really don't see what the problem is unless
A[i][j]
andB[i]
are incompatible for addition, orsum[i]
can't hold a value of the result.
the actual function i'm trying to get is
for (j=0; j < N_tm[1]; j++){
for (i=0; i < N_sp[1]; i++)
{
*P = *R + gm[i][j];
*P++;
}
}
previously instead of gm[][]
, i had used **gm
. but this still doesn't work.
>the actual function i'm trying to get is
That's not helpful and you're not listening to my question. Post the declarations of the relevant variables.
all variables are float.
the solution couldn't be calculate using pointer like that one i post previously.
solution should be used is
P = R + gm[j]
this is only working with array, not pointer.
all variables are float.
the solution couldn't be calculate using pointer like that one i post previously.
solution should be used is
P = R + gm[j]this is only working with array, not pointer.
Maybe someone else is interested in divining your problem from the babble you've given us, but I'm not. Perhaps when you can mange to describe your problem in a useful way and give us enough informatin to help you, I'll lend my assistence.
plz help to write a c program to add to matrix using pointer.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.