My solutions to the advent of code
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.
 
 
 

30 lines
519 B

#include <stdio.h>
int main( int argc, char *argv[] ){
if( argc == 2 ) {
unsigned int last = ~0;
unsigned int increasing = 0;
unsigned int value;
// Read the values into an array
FILE *fp=fopen(argv[1], "r");
while (!feof (fp)){
fscanf(fp, "%d\n", &value);
printf( "value %d\n", value );
if ( value > last )
increasing++;
last = value;
}
fclose(fp);
printf( "%d were increasing\n", increasing );
return 0;
} else {
printf("You need to provide a file\n");
return 1;
}
}