system("ps -ef | grep
n");这一句不对?
至少把n的值传进去吧,你传这么个字符串有啥用???
定义个char command[128];
然后sprintf(command, "ps -ef|grep %d", n);
然后system(command);
这样就可以了。
[QUOTE=jsgylt]#include <IOSTREAM>
#include <STDLIB.H>
#include <STRING>
using namespace std;
int main()
{
string
n;
cout<<"本机磁盘的使用情况如下:"<<ENDL<<ENDL<<ENDL<<ENDL;< p>
system("df -k");
<ENDL<<ENDL<<ENDL<<ENDL;< p>
cout<<"请输入你想监视的进程的名称:";
// cout<<"

lease insert the name of the process which you want to watch!"<<ENDL;* p <>
cin>>n;
<ENDL<<"进程的运行情况如下:";< p>
system("ps -ef | grep
n");
<ENDL;< p>
return 0;
}
为什么那个n传到下面就变了,比如我cin的时候我输入su
正常状态也就是在linux界面上查到只有2个进程
为什么到代码的时候就查处很多乱七八造的东西
如果我写死的话也只有2个进程
请高手赐教[/QUOTE]