>
> nge-run program ini tapi di tengah jalan
> langsung segmentation fault.
> kenapa ya ?
>
> Thanks !
>
> -dikshie-
>
Dugaan saya, mungkin memory yang tersedia tidak mencukupi.
Kalau ndak salah, setidak-tidaknya program ini butuh:
mmax * nmax * jmax * sizeof(double)
= 1000 * 1000 * 1000 * 8
= 8 GigaByte ? ... CMIIW
Coba test dengan: --------------------------------------------o
|
> #include <stdio.h> |
> #include <malloc.h> |
> |
> /* Konstanta */ |
> #define mmax 1000 |
> #define nmax 1000 |
> #define jmax 1000 |
> |
> typedef struct mat1 { |
> double msf[jmax + 2]; |
> } mat1; |
> |
> typedef mat1 *spati[mmax + 1][nmax + 1]; |
> |
> main() |
> { |
> spati z; |
> unsigned long j, m, n; |
> |
> /*Alokasi*/ |
> for (m = 0; m <= mmax; m++) { |
> for (n = 0; n <= nmax; n++) { |
> z[m][n] = (mat1 *)malloc(sizeof(mat1)); |
V
if (z[m][n]==NULL) {
fprintf(stderr, "can't allocate memory for z[%lu][%lu]\n", m, n);
exit(1);
}
> /* printf("%ld %ld\n", m, n); */ /* <-- biar cepet di-comment saja */
> }
> }
> /*Proses*/
> for (j = 0; j <= jmax; j++) {
> for (m = 0; m <= mmax; m++) {
> for (n = 0; n <= nmax; n++) {
> z[m][n]->msf[j] = 23.7;
> printf("%ld %ld %ld\n", j, m, n);
> }
> }
> }
>
> /*Free*/
> for (m = 0; m <= mmax; m++) {
> for (n = 0; n <= nmax; n++)
> free(z[m][n]);
> }
> exit();
>
> }
>
__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/
--------------------------------------------------------------------------------
Utk berhenti langganan, kirim email ke [EMAIL PROTECTED]
Informasi arsip di http://www.linux.or.id/milis.php3
Pengelola dapat dihubungi lewat [EMAIL PROTECTED]