You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
420 B
26 lines
420 B
6 years ago
|
#include <stdlib.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int value = 0;
|
||
|
char *line = NULL;
|
||
|
size_t line_len = 0;
|
||
|
FILE *f = fopen("input", "r");
|
||
|
if (!f) {
|
||
|
perror("input");
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
while (getline(&line, &line_len, f) != -1) {
|
||
|
long number = strtol(line, NULL, 0);
|
||
|
value += number;
|
||
|
}
|
||
|
|
||
|
printf("%d\n", value);
|
||
|
|
||
|
free(line);
|
||
|
fclose(f);
|
||
|
return 0;
|
||
|
}
|