$ prnenv path<ENTER>
/* case sensitive */
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char* argv[], char* env[]){
int i;
int j;
int k;
int check=0;
char p1[30];
char p2[30];
if (argc == 2) {
for (i=0; env[i]!=0 && check==0; i++) {
for (j=0; env[i][j] != '='; j++) {
p1[j]=env[i][j];
}
p1[j]='\0';
if (strcmp(argv[1], p1)==0) {
check=1;
for (k=0; env[i][k+j+1]!='\0'; k++) {
p2[k]=env[i][k+j+1];
}
p2[k]='\0';
}
}
if (check==1)
cout << argv[1] << " = " << p2 << endl;
else
cout << argv[1] << " not found" << endl;
}
return 0;
}
This works but its pretty hideous looking
No comments:
Post a Comment