| #include "stdio.h"
|
| #include "stdlib.h"
|
| #include "errno.h"
|
|
|
| const int add(const int* number1, const int* number2)
|
| {
|
| errno = 0;
|
| if (number1 == NULL || number2 == NULL)
|
| {
|
| errno = EINVAL;
|
| return -1;
|
| }
|
|
|
| return *number1 + *number2;
|
| }
|
|
|
| double* getInput()
|
| {
|
|
|
| double* userInput = malloc(sizeof(double));
|
|
|
| if(scanf("%lf", userInput) != 1)
|
| {
|
| perror("Failed reading from buffer");
|
| free(userInput);
|
| return NULL;
|
| }
|
|
|
| return userInput;
|
| }
|
|
|
| int main() {
|
| double* userInput = getInput();
|
|
|
| if(userInput != NULL)
|
| {
|
| printf("%lf\n", *userInput);
|
| free(userInput);
|
| } else {
|
| fprintf(stderr, "Failed to allocate memory!");
|
| }
|
|
|
| return 0;
|
| }
|