You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 3, 2024. It is now read-only.
https://xqm32.github.io/posts/slicing-string-in-c-language/
搬运一篇笔者在知乎发的文章:C 语言实现字符串切片
基于 Python 的切片的格式实现的 C 语言字符串切片:
#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <string.h> typedef long long SizeType; size_t fgetln(FILE* stream, char* dest, size_t size) { size_t i; for (i = 0, *dest = fgetc(stream); *dest != '\n' && !feof(stream) && --size > 0; ++i, ++dest = fgetc(stream)) ; dest = '\0'; return i; } // 读取一行字符串。 size_t slice(char from, char to, SizeType begin, SizeType end, SizeType interval) { SizeType i; begin += begin < 0 ?
The text was updated successfully, but these errors were encountered: