-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex2.cpp
More file actions
46 lines (41 loc) · 665 Bytes
/
Copy pathex2.cpp
File metadata and controls
46 lines (41 loc) · 665 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdlib.h>
#include <stdio.h>
int aloca(float **ptr, int tam)
{
*ptr = (float*)malloc(sizeof(float)*tam);
if(*ptr == nullptr)
{
return 0;
}
else
{
return 1;
}
}
int aloca(float **ptr, int tam, float valor)
{
*ptr = (float*)malloc(sizeof(float)*tam);
if(*ptr == nullptr)
{
return 0;
}
else
{
for(float *aux = *ptr; aux < (*ptr+tam); aux++)
{
*aux = valor;
}
return 1;
}
}
int main(void)
{
float *v;
aloca(&v,3,2.5);
for(int i = 0; i < 3; i++)
{
printf("%f ",v[i]);
}
free(v);
return 0;
}