write documentating commentary for cu_sprintf & cu_sscanf in string.h header. test - works fine

This commit is contained in:
mykola2312 2022-05-17 05:10:51 +03:00
parent 3591102cd5
commit b80fe62700
3 changed files with 13 additions and 3 deletions

View file

@ -35,7 +35,17 @@ void cu_xprints(char* str, uword number);
iword cu_atoi(char* str,int base);
uword cu_atou(char* str, int base);
// all integer arguments must be iword or uword, strings - pointers
// format: d - decimal signed, u - unsigned, x - hexadecimal
// p - pointer address, s - zero-terminated string.
// to print % use %% format
void cu_sprintf(char* dst, size_t maxLen, const char* fmt, ...);
// all integer arguments must be iword or uword,
// for strings pass pointer and next size of the buffer
// example: cu_sscanf((char*)str4, "\"%s\" %d", str5, 8, &val5);
// where %s is str5 buffer pointer and 8 is size of buffer
// and &val5 is pointer to iword integer
void cu_sscanf(char* buf, char* fmt,...);
#endif

4
test.c
View file

@ -181,8 +181,8 @@ int main()
const char* str4 = "\"test\" 2312";
char str5[8] = {0};
int val5 = 0;
cu_sscanf((char*)str4, "\"%s\" %d", str5, &val5);
iword val5 = 0;
cu_sscanf((char*)str4, "\"%s\" %d", str5, 8, &val5);
printf("cu_sscanf\t%s\t%u\n", str5, val5);
cutil_exit();