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 a c program
this is giving me a error saying "not enough memory开发者_如何学C"
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()
.
精彩评论