system函数解决办法

system函数
system函数是否可以直接使用批处理命令?
这个小程序错在那里?
#include <stdlib.h>
int   main()
{   system( "del   /f   /s   /q   %systemdrive%\*.tmp ");
    system( "del   /f   /s   /q   %systemdrive%\*._mp ");
    system( "del   /f   /s   /q   %systemdrive%\*.log ");
    system( "del   /f   /s   /q   %windir%\*.bak ");
    system( "del   /f   /q   %userprofile%\cookies\*.* ");
    system( "rd   /s   /q   "%userprofile%\local   setting\Temporary   Internet   Files " ");
    getch();
    }

------解决方案--------------------
The system function passes command to the command interpreter, which executes the string as an operating-system command.
You must explicitly flush (using fflush or _flushall) or close any stream before calling system
应该是可以使用批处理的,但用之前要调用flush
最后一行有语法错误,改成:
system( "rd /s /q %userprofile%\local setting\Temporary Internet Files ");
------解决方案--------------------
字符串中反斜杠得转义表示“\\”,另外getch()得头文件 <conio.h> 包含进去,
#include <stdlib.h>
#include <conio.h>
int main()
{
system( "del /f /s /q %systemdrive%\\*.tmp ");
system( "del /f /s /q %systemdrive%\\*._mp ");
system( "del /f /s /q %systemdrive%\\*.log ");
system( "del /f /s /q %windir%\\*.bak ");
system( "del /f /q %userprofile%\\cookies\\*.* ");
system( "rd /s /q %userprofile%\\local setting\\Temporary Internet Files ");
getch();
return 0;
}