简体   繁体   中英

system call giving not enough memory in c++

I was trying to enter list of files in a file by using command

system("dir *.txt /b :gen> file.txt");

in ac program

this is giving me a error saying "not enough memory"

but when i am writing the same code (dir *.txt /b :gen >file.txt) in cmd it is working fine

and also i tried some other codes also like "cd" they are also giving same error

error is being displayed if i use perror("error");

You can't rely on perror() to correctly report status from a process started using system() .

All that perror() does is inspect the value of errno , but that's not set by system() .

See the documentation on how to actually catch status information from system() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM