Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Cで変数の値を代入する方法を知りたいです。
execl ("/bin/cat","cat","/proc/30828/status", (char *)0 );
「30828」は値が固定されていないため、変数に変更できるようにしたいと考えています。あなたができるSHELLのようなことができるかどうか疑問に思っています。たとえば、シェルでは次のことができます。
K=`ls -lis $i` echo $K
snprintf()PID を文字列変数に置き換えるために使用します。
snprintf()
char statusfile[30]; sprintf(statusfile, sizeof statusfile, "/proc/%d/status", pid); execl("/bin/cat","cat",statusfile, (char *)0 );