tags:

views:

53

answers:

2

i want to change this code below for the inwashfile to be able to load from any directory instead of loading from the tech_projects environmental variable.

  /**Get projects directory from environment variable****************/
 strcpy(pjects.arr, getenv("Tech_Projects"));

  pjects.arr[strlen(pjects.arr)] = '\0';

  if (strcmp(inwashfile.arr, "null") != 0)
  {
    for (d=2;d<inwashfile.len;d++)
    {
      tempfile.arr[d-2] = inwashfile.arr[d];
    }      
    memset(inwashfile.arr, '\0', 255);    

    strcpy(inwashfile.arr, pjects.arr);
    strcat(inwashfile.arr, tempfile.arr);

    inwashfile.len = strlen(inwashfile.arr);
    inwashfile.arr[inwashfile.len] = '\0';
    do_wash[0] = 'T';
  }
  else
  {
    do_wash[0] = 'F';
  }
printf("3\n");
  do_wash[1] = '\0';
A: 
 /**Get projects directory from environment variable****************/
 /* You need to replace this line with wherever you want to get the
    file name from. Either request it from the user, pull it from a
    configuration file or read it from the command line */
 strcpy(pjects.arr, getenv("Tech_Projects"));

  /* this line does absolutely nothing. strlen() relies on the string
     already being null-terminated */
  pjects.arr[strlen(pjects.arr)] = '\0';

  if (strcmp(inwashfile.arr, "null") != 0)
  {
    for (d=2;d<inwashfile.len;d++)
    {
      tempfile.arr[d-2] = inwashfile.arr[d];
    }      
    memset(inwashfile.arr, '\0', 255);    

    strcpy(inwashfile.arr, pjects.arr);
    strcat(inwashfile.arr, tempfile.arr);

    inwashfile.len = strlen(inwashfile.arr);
    inwashfile.arr[inwashfile.len] = '\0';
    do_wash[0] = 'T';
  }
  else
  {
    do_wash[0] = 'F';
  }
printf("3\n");
  do_wash[1] = '\0';
OJ
i tried replacing the line with : strcpy(pjects.arr,getdir([cdirectory,[ctext,[ccaption,[nflag,[clrootonly]]]]])), but it give an error for gc_load.obj : error LNK2001: unresolved external symbol _getdirgc_load.exe : fatal error LNK1120: 1 unresolved externals
Monica
A: 

It could be

strcpy(pjects.arr, argv[ 1 ] );

and the directory named could be passed from the command line, e.g.

$ myprogram /user/foo
ArunSaha