I try to use _popen() to view files. When I write one word command like ipconfig or dir it works fine. However when I try something with space in it like cd .. or cd C:\, it won't work(it won't change the directory), the program just does nothing. I don't get a error. I'm on a Windows machine. I don't know if it has anything to do with the spaces. I tried something like this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Windows.h>
int main()
{
while (1)
{
char buff[500];
char input[100];
printf("Command: ");
fgets(input, 100, stdin);
FILE* f = _popen(input, "r");
while (fgets(buff, 200, f) != NULL)
{
printf("%s", buff);
}
_pclose(f);
}
}
#includestatements and anint main().