int i,j,m,n; double** array; int main(void) { printf("strings pls:"); scanf_s("%d",&m); printf("columns pls:"); scanf_s("%d", &n); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { array[i][j] = rand(); } printf("&lf", array[i][j]); } getchar(); return 0; } Closed due to the fact that off-topic participants ߊߚߤߘ , cheops , Jarvis_J , AivanF. , Kromster Jul 17 '18 at 11:19 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - ߊߚߤߘ, AivanF.
|
2 answers
Just not allocated memory for the array ...
Before writing in array , it is tedious to allocate memory. About
array = malloc(m*sizeof(double*)); for(int i = 0; i < m; ++i) array[i] = malloc(n*sizeof(double)); And also - this
printf("&lf", array[i][j]); will just output &lf :)
- It does not work ((How the code will look like - user237701
|
и все ровно ошибка( int m,n,i,j; double **arrayl; int main() { printf("strings pls:"); scanf_s("%d",&m); printf("columns pls:"); scanf_s("%d", &n); arrayl = (double**)calloc(n,sizeof(double*)); for (int j = 0; j < m; j++) { arrayl = (double**)calloc(m, sizeof(double)); } for (i = 0; i < m; i++) { for (j = 0; j <n; j++) { arrayl[i][j] = rand() % 30; } } printf("&lf", arrayl[i][j]); getchar(); return 0; }
- rightly. You have been given a code above - compare with yours. - Igor
- and how to display an array? - user237701
- first allocate memory for it as shown in the answer above - Igor
|
rows, but notstrings. - andy.37