| | |
pointer and array arithmetic
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Mar 2006
Posts: 4
Reputation:
Solved Threads: 0
the solution i need to obtain is
sum[i] = A[i][j] + B[i];
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[i] and B[i] 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;
}
sum[i] = A[i][j] + B[i];
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[i] and B[i] 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;
}
•
•
Join Date: Mar 2006
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Narue
>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] and B[i] are incompatible for addition, or sum[i] can't hold a value of the result.
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.
•
•
•
•
Originally Posted by yaya
all variables are float.
the solution couldn't be calculate using pointer like that one i post previously.
solution should be used is
P[i] = R[i] + gm[i][j]
this is only working with array, not pointer.
New members chased away this month: 3
![]() |
Similar Threads
- Pointer to array (C++)
- C++: compile error "subscripted value is neither array nor pointer" (C++)
- simpe pointer arithmetic (C)
- Dynamic Array and Pointer (C++)
- Character Array to character pointer. (C)
- sorting an array of string (C)
Other Threads in the C Forum
- Previous Thread: How to flip bits
- Next Thread: Can't get around this crash
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opensource overwrite owf pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi






