Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

While using sprintf like this

sprintf("%.40s",str);

I want to give a value like strlen(str) in place of 40.How do I do that? I tried replacing 40 with strlen(str), doesn't work. giving a value like

#define len strlen(str)

and using %.len doesnt work either since %.len is in "".

share|improve this question
need to try out if #define return strlen(str); works – Anurag Nov 7 '12 at 17:59
Hi and Welcome to AskUbuntu. We love ubuntu specific programming questions. This is more generic - it should be asked on StackOverflow itself. – fossfreedom Nov 7 '12 at 20:03

closed as off topic by Jai, belacqua, fossfreedom Nov 7 '12 at 20:02

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.