diff --git a/string.c b/string.c index f584627..fbdcff2 100644 --- a/string.c +++ b/string.c @@ -353,7 +353,7 @@ void cu_sscanf(char* buf, char* fmt, ...) cu_va_start(&ap); uword idx; - uword len,maxLen; + uword len, maxLen; union { iword* iptr; uword* uptr; diff --git a/string.h b/string.h index b20dfd4..e81f812 100644 --- a/string.h +++ b/string.h @@ -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 \ No newline at end of file diff --git a/test.c b/test.c index 4db07a9..895d048 100644 --- a/test.c +++ b/test.c @@ -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();