next up previous contents
Next: Display of the level Up: Complement: the debugger gdb Previous: The command where

Parameter passing in UNIX

e now have a tool, let us call it fem2gnu to translate a .msh file into a .gnu file. It would be nice to be able to type

fem2gnu micro

to translate the file "micro.msh" into a "micro.gnu" file.

The following program solves the problem

main (int argc, char **argv)
{
  char* filein =  new char[256];
  char* fileout = new char[256];
  if (argc != 2) //nb of strings on unix command
  {
    cout << "Check syntax of call to fem2gnu"<<endl;
    exit(0);
  }
  strcpy(filein,argv[1]); //second string copied
  strcat(filein,".msh");  //(1st string is prog name)
  strcpy(fileout,argv[1]);
  strcat(fileout,".gnu"); // suffix added
  Triangulation g(filein);
  g.gnu(fileout);

}



Pironneau Olivier
Jeudi 12 mars 1998 16:06:41