fix type definition for calloc'd lineptr
This commit is contained in:
parent
4b59767dc6
commit
b8ec732f61
1 changed files with 3 additions and 3 deletions
|
@ -21,15 +21,15 @@ uintmax_t factorial_iter(uintmax_t n) {
|
|||
|
||||
int main(void) {
|
||||
size_t bufsize = 1024;
|
||||
char **lineptr = calloc(bufsize, sizeof(char));
|
||||
char *lineptr = calloc(bufsize, sizeof(char));
|
||||
fputs("Enter number to factor: ", stdout);
|
||||
int err = getline(lineptr, &bufsize, stdin);
|
||||
int err = getline(&lineptr, &bufsize, stdin);
|
||||
if(err == -1) {
|
||||
puts("Error reading line from user input");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uintmax_t user_input = abs(atoi(*lineptr));
|
||||
uintmax_t user_input = abs(atoi(lineptr));
|
||||
printf("\nRecursive factorial for number: %ju\n", factorial(user_input));
|
||||
printf("Iterative factorial for number: %ju\n", factorial_iter(user_input));
|
||||
free(lineptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue