Print part of a string in C

后端 未结 4 1728
有刺的猬
有刺的猬 2020-12-15 07:52

Is there a way to only print part of a string?

For example, if I have

char *str = \"hello there\";

Is there a way to just print

4条回答
  •  失恋的感觉
    2020-12-15 08:43

    This will work too:

    fwrite(str, 1, len, stdout);
    

    It will not have the overhead of parsing the format specifier. Obviously, to adjust the beginning of the substring, you can simply add the index to the pointer.

提交回复
热议问题