Talk:Esercizio 1, prova pratica 12/02/2009

From Sistemi Operativi
Revision as of 12:42, 26 November 2014 by Davide.boldrin (talk | contribs) (Created page with "#include <stdio.h> #include <unistd.h> #include <errno.h> void invarg(int Qparametri, char* Rargv[], char* argv[]); int main(int argc, char* argv[]){ int Qparametri=argc-1;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  1. include <stdio.h>
  2. include <unistd.h>
  3. include <errno.h>

void invarg(int Qparametri, char* Rargv[], char* argv[]);

int main(int argc, char* argv[]){ int Qparametri=argc-1; char *Rargv[Qparametri]; invarg(Qparametri, Rargv, argv); printf("%s\n","il nuovo vettore dei parametri è stato creato con successo");

  	execvp(Rargv[0], Rargv);
 	 perror("execvp");
  return 1;

}

void invarg(int Qparametri, char* Rargv[], char* argv[]){ Rargv[0]=argv[1]; Rargv[Qparametri]=NULL; int i=2; while(argv[i]!=NULL){ Rargv[Qparametri-1]=(argv[i]); i++; Qparametri--; }

}