Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Unable to copy string
  2. //**My Code**
  3. struct dirs_later {
  4.     const char *findme;
  5.     struct dirent *dptr;
  6.     struct stat this_lstat;
  7.     char *relative_path;
  8.     const char *type_str;
  9.     DIR * dir;
  10. };
  11.  
  12. ....
  13. struct dirs_later *new_dir = malloc(sizeof(struct dirs_later*));
  14. ...
  15. char *relative_path2 = strdup(relative_path);
  16. if (NULL != new_dir) {
  17.     new_dir->findme = findme;
  18.     new_dir->dptr = dptr;
  19.     new_dir->this_lstat = *this_lstat;
  20.     new_dir->relative_path = relative_path2;
  21.      new_dir->type_str = type_str;
  22.     }
  23.        
  24. //**My Code**
  25. char *relative_path2 = malloc(strlen(relative_path) + 1 * sizeof(char));
  26. //check for NULL
  27. strcpy(relative_path2, relative_path);
  28.        
  29. struct dirs_later *new_dir = malloc(sizeof(struct dirs_later*));
  30.        
  31. struct dirs_later *new_dir = malloc(sizeof(struct dirs_later));