3
I have a problem related to reading a array that produces the error
Segmentation Fault (core dumped )
This is only the beginning of code development, but already presents an error after reading the first element of array.
#include <stdio.h>
#include <stdlib.h>
void LerArray( int numElementos , float * elemArray ){
int i;
float num ;
for( i = 0 ; i < numElementos ; i++ ){
printf("Digite um numero para seu array: ");
scanf("%f", num );
*( elemArray + i ) = num ;
printf("/n/n");
}
}
int main (){
int numElementos;
printf("Oi !!! Quantos elementos vc quer armazenar : ");
scanf("%d", &numElementos );
system("clear");
float * vetorNum ;
vetorNum = ( float * ) malloc( numElementos );
LerArray( numElementos , vetorNum );
return 0 ;
}
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero