Question: C help needed? Can anyone tell me how to execute DOS commands using C? I tried the following but it isn't working.\n#include<stdlib.h>\n#include<stdio.h>\nint main(void)\n{\nprintf("Going to execute a C command");\nsystem("dir");\nreturn 0;\n}\nIam just getting the printf statement executed. The dir command isn't working plz help!

Answer: I dont code much in windows, but what little I have seen, system command work just as well there.\nI tried your code in Linux (with ls replaceing dir) and I got the expected result. So the program works for sure.\ntell you what, check if adding a &#92;n at the end of the print line changes things.\nI have a feeling, you are running into buffer related issues.\nThe other thing that you can do is to change the command from dir to something like "mkdir a"
This question from the Yahoo Q&A forum is categorized in the topic: Sports