Anshul
Anshul

Reputation: 1446

stralloc implementation of string in qmail

what is the ending delimiter of string used through stralloc function in qmail(MTA) code???

stralloc str;
stralloc_copys(&str,"testing");
printf("%s\n", str.s);

It actually prints

testingZjklfjndf

What is the correct way to print the content???

Upvotes: 1

Views: 212

Answers (3)

user2193878
user2193878

Reputation: 11

stralloc_0 will terminate the rest of the things after Z. But when u want to print , print till str.len.

Upvotes: 1

user2071078
user2071078

Reputation:

As such there is no delimiter but you can find Z at the end of every string stored by stralloc. the data stored in stralloc is looked-up though len only.

and as ansh already mentioned dont try to print the data through printf instead run a for loop for len times on the string.

for more reference: http://cr.yp.to/lib/stralloc.html

Upvotes: 2

user2077511
user2077511

Reputation:

in stralloc \0 is also a valid content so dont try to print the data through printf

Upvotes: 1

Related Questions