Esempio n. 1
0
static char	*list_to_send(unsigned int s, char *print)
{
  DIR		*dir;
  struct dirent	*tmp;

  if ((dir = opendir(".")) == NULL)
    {
      my_perror(__func__, __LINE__, __FILE__, FAILURE);
      return (NULL);
    }
  while ((tmp = readdir(dir)) != NULL)
    {
      if ((print = realloc(print, s + strlen(tmp->d_name) + 2)) == NULL)
	{
	  my_perror(__func__, __LINE__ - 2, __FILE__, FAILURE);
	  return (NULL);
	}
      strcpy(print + s, tmp->d_name);
      tricky(print, &s);
    }
  if (closedir(dir) == -1)
    {
      my_perror(__func__, __LINE__ - 2, __FILE__, FAILURE);
      return (NULL);
    }
  return (print);
}
Esempio n. 2
0
int main(void) {
  float *a = createvect(NUM);

  // assign an int
  setvect(NUM, a, 1);
  assignInt(NUM, a);
  printf("0: a = ");
  printvect(NUM, a);
  printf("\n");
  
  // assign then reassign an int
  setvect(NUM, a, 1);
  reassignInt(NUM, a);
  printf("1: a = ");
  printvect(NUM, a);
  printf("\n");
  
  // assign a foat
  setvect(NUM, a, 1);
  assignFloat(NUM, a);
  printf("2: a = ");
  printvect(NUM, a);
  printf("\n");
  
  // assign then reassign a float
  setvect(NUM, a, 1);
  reassignFloat(NUM, a);
  printf("3: a = ");
  printvect(NUM, a);
  printf("\n");
  
  // tricky example
  setvect(NUM, a, 1);
  tricky(NUM, a);
  printf("4: a = ");
  printvect(NUM, a);
  printf("\n");

  return 0;
}