cosms-core/tests/main.c

23 lines
660 B
C
Raw Normal View History

#include <cosms-core/file.h>
#include <stdio.h>
int main(void) {
unsigned long long buffer_size;
char *buffer;
CosmsFileError error = cosms_core_file_read("test.txt", &buffer, &buffer_size);
if (error != COSMS_FILE_OK) {
fprintf(stderr, "error(%d): %s\n", error, cosms_core_file_error_string(error));
} else {
printf("file read with content:\n%s\n", buffer);
}
char *temp_buffer = "Hello, World!";
error = cosms_core_file_write("write-file.txt", temp_buffer, 13, true);
if (error != COSMS_FILE_OK) {
fprintf(stderr, "error(%d): %s\n", error, cosms_core_file_error_string(error));
}
return 0;
}