Malloc.h not found - C (СИ)
Формулировка задачи:
Всем привет, написал программу, но ругается "malloc.h not found"
Вот собственно код, пишу на Xcode
#include <stdio.h>
#include <malloc.h>
#define myt int
// jghtltkbyt nbgjd
typedef struct Line { // jlyjvthysq vfccbd
int SIZE; // hfpvthb
int *l;
};
typedef struct Matrix{
int lines;
Line *a;
};
// prototypes of func
void GetMatrix(Matrix *); // sozdanie matrizu
void OutMatrix(Matrix);
int Nolvch(int *);
int Summ(Matrix *);
void Vector(Matrix *,Line *);
int main()
{
Matrix matr = { 0, NULL };
Line b = { 0, NULL };
int c;
do{
Matrix m;
GetMatrix(&m);
OutMatrix(m);
Vector(&matr, &b);
scanf_s("%d", &c);
} while (c != 0);
return 0;
}
void GetMatrix(Matrix * x)
{
printf("vvedi kolvo strock: ");
scanf_s("%d", &x->lines, sizeof(int));
x->a = (Line *)malloc(x->lines * sizeof(Line));
for (int i = 0; i < x->lines; ++i)
{
printf("Sizeof(m[%i]) = ", i);
scanf_s("%i", &x->a[i].SIZE, sizeof(x->a[i].SIZE));
x->a[i].l = (int *)malloc(x->a[i].SIZE*sizeof(int));
for (int j = 0; j < x->a[i].SIZE; j++)
{
printf("\tm[%d,%d] = ", i,j);
scanf_s("%i", &x->a[i].l[j], sizeof(int));
}
}
}
int Nolvch(int a)
{
int i = 0;
int n = 0;
while (a > 0)
{
n = a % 10;
if (n = 0)
{
return 1;
}
a = a / 10;
}
return 0;
}
int Summ(Line *a)
{
int *summ;
for (int j = 0; j <a->SIZE; j++)
{
if (Nolvch(a->l[j]) == 0)
*summ += a->l[j];
}
return *summ;
}
void vector(Matrix *matr, Line *b)
{
int i, j, n, m, c, flag, s;
Line PLINE;
int *pElem;
n = matr->lines;
PLINE= matr->lines;
n = matr->n;
b->m = n;
b->line = (int *)calloc(n, sizeof(int));
for (i = 0; i < n; i++){
s = 0;
m = pLine->m;
pElem = pLine->line;
for (j = 0; j < m; j++){
c = *pElem;
flag = 1;
while ((c > 0) && (flag == 1)){
if (c % 10 == 0) flag = 0;
c /= 10;
};
if (flag) s += *pElem;
pElem++;
}
b->line[i] = s;
pLine++;
}
output_v(b);
}
void OutMatrix(Matrix x)
{
printf("matriza : \n");
for (int i = 0; i < x.lines; i++)
{
for (int j = 0; j < x.a[i].SIZE; j++)
{
printf("%i%s", x.a[i].l[j]," ");
}
printf("\n");
}
}Решение задачи: «Malloc.h not found»
textual
Листинг программы
#include <stdlib.h>