hi Ive been working on a program that finds hidden files copies the contents and then deletes the hidden file so far ive got

system("set OLDDIR=%CD%&&@ECHO OFF&&ECHO Finding Hidden Files&&dir /ah&&PAUSE");
printf("Please Choose The Files You Want To repair separated by spaces\n");
scanf("%c",&d1);
getchar();
string cmd="echo"+d1;
system(cmd.c_str());

but im having a problem transferring the variable d1 to the system() command any help would be greatly appreciated
thanks in advance

Recommended Answers

All 4 Replies

You can not set environment variables like that because they are set only while the system() function is running. As soo as system() returns to your program the new environment variables disappear. Its identical behavior in MS-Windows and *nix operating systems.

yea but i dont want them to keep the values outside of system() u understand i want to be able to use the user declared values within the system environment thats the main thing i need the user to input the value and then i need it to be used in the system() for one time

I suppose you could create a batch file that would do it then call it from system().

you can cr8 a batch file that check attributes of hidden files and then write to batch file after you retrieve them write deleting attribute but thats long task i think there api for these stuff

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.