I am trying to calculate result of the floor function for floats <= 9999.
#include <stdlib.h>
include <stdio.h>
#include "string.h"
int main(int argc, char* argv[]) {
int i, j, k;
int x[1000];
for(i = 0; i < 10000; ++i){
x[i] = i;
}
printf("Enter a float in 0..9999: ");
scanf("%d", k);
tester(x, k);
}
int tester(int* c, int k) {
printf("x[%d] = %d\n", k, c[k]);
}
When compiler came to;
for(i = 0; i < 10000; ++i){
x[i] = i;
}
it gives segmentation fault;
x[i] = i;
here.
I have already checked similar questions about assigning segmentation fault but I couldn't find any solution way. Can anyone help?
1000]; and for(i = 0; i <10000; ++i) Time to count 0 digits.Enter a floattointegersince%din scanf interprets input as decimal."%d"(integer in decimal format) is wrong format specifier forfloat– you need to use"%f"instead, otherwise undefined behaviour.sizeof(array)/sizeof(*array).