getpid是一种函数,功能是取得进程识别码,许多程序利用取到的此值来建立临时文件,以避免临时文件相同带来的问题。
示例一: #include <stdio.h> #include <process.h> int main( void ) { /* If run froom command line, shows different ID for * command line than for operating system shell. */ printf( "Process id: %d\n", _getpid() ); return 0; } 示例二: #include<unistd.h> main() { printf(“pid=%d\n”,getpid()); } 执行: pid=1494 /*每次执行结果都不一定相同*/
原文:https://www.cnblogs.com/hshy/p/11848325.html