diff options
| author | tylov <[email protected]> | 2023-07-20 15:09:10 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-07-20 15:12:29 +0200 |
| commit | 900295256d825fc323149cd223c49787f32a3696 (patch) | |
| tree | 6c79cf4209e3975bb6865e2940b9cb56ea469c73 /misc/examples/read.c | |
| parent | 224a04f7fa7549ed94d2a1415eb25829e39a7cca (diff) | |
| download | STC-modified-900295256d825fc323149cd223c49787f32a3696.tar.gz STC-modified-900295256d825fc323149cd223c49787f32a3696.zip | |
Moved examples to sub-directories. Added cotask1.c cotask2.c examples.
Diffstat (limited to 'misc/examples/read.c')
| -rw-r--r-- | misc/examples/read.c | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/misc/examples/read.c b/misc/examples/read.c deleted file mode 100644 index b12f7409..00000000 --- a/misc/examples/read.c +++ /dev/null @@ -1,27 +0,0 @@ -#define i_implement -#include <stc/cstr.h> -#include <stc/algo/raii.h> -#define i_key_str -#include <stc/cvec.h> -#include <errno.h> - -cvec_str read_file(const char* name) -{ - cvec_str vec = cvec_str_init(); - c_with (FILE* f = fopen(name, "r"), fclose(f)) - c_with (cstr line = cstr_null, cstr_drop(&line)) - while (cstr_getline(&line, f)) - cvec_str_push(&vec, cstr_clone(line)); - return vec; -} - -int main(void) -{ - int n = 0; - c_with (cvec_str vec = read_file(__FILE__), cvec_str_drop(&vec)) - c_foreach (i, cvec_str, vec) - printf("%5d: %s\n", ++n, cstr_str(i.ref)); - - if (errno) - printf("error: read_file(" __FILE__ "). errno: %d\n", errno); -} |
