diff options
Diffstat (limited to 'tests/files.cpp')
-rw-r--r-- | tests/files.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/files.cpp b/tests/files.cpp new file mode 100644 index 00000000..a07ef42b --- /dev/null +++ b/tests/files.cpp @@ -0,0 +1,33 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +int main() { + FILE *file = fopen("somefile.binary", "rb"); + assert(file); + + fseek(file, 0, SEEK_END); + int size = ftell(file); + rewind (file); + printf("size: %d\n", size); + + char *buffer = (char*) malloc (sizeof(char)*size); + assert(buffer); + + size_t read = fread(buffer, 1, size, file); + assert(read == size); + + printf("data: %d", buffer[0]); + for (int i = 1; i < size; i++) + printf(",%d", buffer[i]); + printf("\n"); + + fclose (file); + free (buffer); + + fwrite("texto\n", 1, 6, stdout); + fwrite("texte\n", 1, 6, stderr); + + return 0; +} + |