How to create a string using placeholder (%s) in c -


normally can use placeholder %s in printf(), fprintf() function.

i want use placeholder create string using %s. that

 char fname[200] = "c:\\users\\%s\\desktop\\result", getenv("username");   // getenv() function return current user name   // fname "c:\\users\\zobayer\\desktop\\result" 

i know in c++ can create stringstream

std::stringstream ss; ss << "c:\\users\\" << getenv("username") << "\\desktop\\result"; 

but in c how can create type of string ? please me.

and advance me.

try sprintf. print string.

char fname[200]; sprintf(fname, "c:\\users\\%s\\desktop\\result", getenv("username")); 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -