Save information from sprintf to a variable
问题 is it possible to save information gather from a sprintf into a variable? The lines of code below are an example to better illustrate my question. char fileName; fileName = sprintf(command, "find -inum %i -type f", iNode); The purpose is to find the file name associated with the inode number, then run "stat" on that file name. 回答1: I think you want something like this: FILE *fp; char cmd[1024]; char filename[1024]; sprintf(cmd, "find -inum %i -type f", iNode); fp = popen(cmd); fgets(filename,