Hi,
In a while loop I need to clear out a value in a char[20] data type and then reassign another value to it, so that comparisons can be made.
the char is called folder 1 in the following code, but the compilier errors with "left operand must be l-value".
Code:
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <time.h>
#include <conio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
int main(void)
{
FILE *fp;
char filename[20];
char *test;
char folder1[20] = "";
char buf1[80];
char buf2[80];
time_t filecreate;
struct tm *ptr;
struct _finddata_t c_file;
long hfile;
if ((hfile = _findfirst("C:\\Program Files\\Microsoft Visual C++ Toolkit 2003\\samples\\*.out",&c_file)) == 1L)
printf("a");
else
{
printf("%-12s %.24s % 9ld\n",c_file.name,ctime(&(c_file.time_write)),c_file.size);
/* filecreate = ctime(&(c_file.time_write));*/
ptr = localtime(&(c_file.time_write));
strftime(buf1,80, "%d%m%Y",ptr);
printf("%s",buf1);
if(mkdir(buf1) != 0);
{}
strcat(folder1,buf1);
printf("\nfolder1%s",folder1);
if(file_copy(c_file.name,buf1) != 0)
{printf("smeg");}
}
/*_findclose(hfile);*/
/*time to loop the other files with same extension as the first file*/
while( _findnext( hfile, &c_file ) == 0 )
{
ptr = localtime(&(c_file.time_write));
strftime(buf1,80, "%d%m%Y",ptr);
printf("\nnewfilename %s", c_file.name);
printf("\nnewtime%s",buf1);
if (folder1 == buf1 )
{
if(file_copy(c_file.name,buf1) != 0)
{printf("smeg");}
}
else
{
if(mkdir(buf1) != 0);
{}
folder1 = ""; strcat(folder1,buf1);
printf("\nfoldera%s",folder1);
if(file_copy(c_file.name,buf1) != 0)
{printf("smeg");}
}
}
_findclose( hfile );