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

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -