Hello,

I'm trying create basic script for renaming files with date included. If I rename only char oldname to newname without date included it's working but when I include date it seems like it's string after and renamed can be only char... Even I tried restream string back to char I have a problems as

initializer fails to determine size of `newname1' because of "#define MAX_DATE 12"

I'm trying find way how basically rename files from original to new with current date included...

Any idea?

Example:

----------------------------------------

Code:
#include <sstream>
#include <time.h>

#define MAX_DATE 12



   time_t now;
   char the_date[MAX_DATE];
   the_date[0] = '\0';

   now = time(NULL);

   if (now != -1)
   {
      strftime(the_date, MAX_DATE, "%d_%m_%Y", gmtime(&now));
   }
   string datex = the_date;
   string file1 = "filename" + datex + ".TXT";
   stringstream ss;
   char replace1[] = "";
   ss << file1;
   ss >> replace1;


   int result1;
  char oldname1[] = "FILENAME.TXT";
  char newname1[] = replace1;
  result1= rename( oldname1 , newname1 );
  if ( result1 == 0 )
    puts ( "File successfully renamed" );
  else
    perror( "Error renaming file " );
-----------------------------------------------------------