14-12-2010, 22:22
|
|
|
חבר מתאריך: 15.07.02
הודעות: 1,027
|
|
C - העברת מערך דו-מימדי לפונקציה ע"י מצביע ?
אני מנסה להעביר לפוקציה מסויימת כתובת של מערך ע"י שימוש במצביע, הקומפיילר עובר בשלום, אך ברגע קליטה לתוך המערך התוכנית מתקבל הפלט הבא:
קוד:
Enter a number to cell [0][0]:
2
Program received signal: “EXC_BAD_ACCESS”.
להלן קוד התוכנית (רק הפונקציה):
קוד PHP:
#include <stdio.h> #define N 6 #define M 8
void my_fill(float *arpt[M]) { int i, j; for (i=0; i < N; i++) { for (j=0; j < M; j++) { printf("Enter a number to cell [%d][%d]: \n", i,j); scanf("%f", &arpt[i][j]); } } } int main(void) { float array_A[N][M]; my_fill(array_A); return 0; }
מה לא נכון כאן?
_____________________________________
ציטוט:
Different people use different tools, but its mostly morons who pretend that the problems with PHP actually matter.
|
|