From 683ba37c61e597d1cab5e64beda92d6cd117c246 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 18 Jan 2023 15:37:28 +0800 Subject: [PATCH] update readme --- README.md | 45 +++------------------------------------------ README_zh.md | 45 +++------------------------------------------ 2 files changed, 6 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index a1e3ad3f4..f79b71e27 100755 --- a/README.md +++ b/README.md @@ -239,58 +239,19 @@ $ make ```c #include "tbox/tbox.h" -int main(int argc, char** argv) -{ - // init tbox +int main(int argc, char** argv) { if (!tb_init(tb_null, tb_null)) return 0; - // trace - tb_trace_i("hello tbox"); - - // init vector tb_vector_ref_t vector = tb_vector_init(0, tb_element_str(tb_true)); - if (vector) - { - // insert item + if (vector) { tb_vector_insert_tail(vector, "hello"); tb_vector_insert_tail(vector, "tbox"); - // dump all items - tb_for_all (tb_char_t const*, cstr, vector) - { - // trace + tb_for_all (tb_char_t const*, cstr, vector) { tb_trace_i("%s", cstr); } - - // exit vector tb_vector_exit(vector); } - - // init stream - tb_stream_ref_t stream = tb_stream_init_from_url("http://www.xxx.com/file.txt"); - if (stream) - { - // open stream - if (tb_stream_open(stream)) - { - // read line - tb_long_t size = 0; - tb_char_t line[TB_STREAM_BLOCK_MAXN]; - while ((size = tb_stream_bread_line(stream, line, sizeof(line))) >= 0) - { - // trace - tb_trace_i("line: %s", line); - } - } - - // exit stream - tb_stream_exit(stream); - } - - // wait - tb_getchar(); - - // exit tbox tb_exit(); return 0; } diff --git a/README_zh.md b/README_zh.md index 9f642817e..b3b9a3000 100755 --- a/README_zh.md +++ b/README_zh.md @@ -246,58 +246,19 @@ $ make ```c #include "tbox/tbox.h" -int main(int argc, char** argv) -{ - // init tbox +int main(int argc, char** argv) { if (!tb_init(tb_null, tb_null)) return 0; - // trace - tb_trace_i("hello tbox"); - - // init vector tb_vector_ref_t vector = tb_vector_init(0, tb_element_str(tb_true)); - if (vector) - { - // insert item + if (vector) { tb_vector_insert_tail(vector, "hello"); tb_vector_insert_tail(vector, "tbox"); - // dump all items - tb_for_all (tb_char_t const*, cstr, vector) - { - // trace + tb_for_all (tb_char_t const*, cstr, vector) { tb_trace_i("%s", cstr); } - - // exit vector tb_vector_exit(vector); } - - // init stream - tb_stream_ref_t stream = tb_stream_init_from_url("http://www.xxx.com/file.txt"); - if (stream) - { - // open stream - if (tb_stream_open(stream)) - { - // read line - tb_long_t size = 0; - tb_char_t line[TB_STREAM_BLOCK_MAXN]; - while ((size = tb_stream_bread_line(stream, line, sizeof(line))) >= 0) - { - // trace - tb_trace_i("line: %s", line); - } - } - - // exit stream - tb_stream_exit(stream); - } - - // wait - tb_getchar(); - - // exit tbox tb_exit(); return 0; }