I am looking for a way to get floating point input from a user.
My way of going about this is to use a self-made getstrn function and plug that into another function which would convert the string into a double.
My safe get string:
void safeGetString(char arr[], int limit){
int c, i;
i = 0;
c = getchar();
while (c != '\n'){
if (i < limit -1){
arr[i] = c;
i++;
}
c = getchar();
}
arr[i] = '\0';
}
What would be the best way to write this get_double function?