With the struct declaration:
struct Dat {
   int count; // number of files
   string *files;
   Dat(): count(0), files(nullptr) {}
   ~Dat() {
      delete[] files;
   }
}
And then I built files like so:
buildFiles(int argc, char *argv, Dat my) {
   my.files = new string[my.count]; // my.files = new string[3]
   int filedex = 0;
   for (int i=0; i<argc; ++i) {
      if (some condition for argv[i]) { // only looking for filenames from argv
         my.files[filedex] = argv[i]; // store filename in my structure
         filedex++;
      }
   }
   if (filedex != my.count) cerr << "BAD";
}
int main (int argc, char *argv[])
{
   Dat my;
   // functions that define my.count to be non-zero, e.g. my.count = 3
   buildsFiles(argc, argv, my);
   // blahblah
   return 0;
} 
How do I now delete the dynamically allocated variables, files?
I've tried delete[] my.files and delete[] my->files but neither seem to work. I'm very new to c++ so any help would be much appreciated.
 
     
     
    