APPFS
Advanced practical programming for scientists
|
Appfs Exercise 1: direct read input. More...
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <assert.h>
Go to the source code of this file.
Macros | |
#define | MAX_NUMS ((INT_MAX >> 5) + 1) |
Maximum number of 32 bit ints we need to store bits. More... | |
#define | BUF_NUMS 4096 |
read buffer size More... | |
Functions | |
int | main (int argc, char **argv) |
Program to read a file with binary positive 32 bit integers, sort the numbers and print them sorted. More... | |
gcc -O3 -Wall -std=c99 -o ex1 ex1.c
Using direct read() for input
Definition in file ex1a.c.
int main | ( | int | argc, |
char ** | argv | ||
) |
Actually, the numbers are not sorted. There is an array with one bit for each possible number. Upon reading the respective bit is set for the number recognized. At the end the array is scanned in order and the numbers present are printed.
argv | [1] name of file to read |
Definition at line 31 of file ex1a.c.