> So, I guess I'm asking, anyone have any tips for checking a blank file
> where I wouldn't lose that head character? (as it is essential for strcmp
> later in the function)
> Or is there anyway to directly get the output from the system call into a
> char* or something, where I could then just parse the information within
> the code itself instead of having to write it to a file?
FILE *pp;
char buf[1024];
sprintf(buf, "ls -1 %s/%s.*", PLAYER_DIR, lookup_name);
pp = popen(buf, "r");
fgets(buf, sizeof(buf), pp); // non-lossy primer read
while (!feof(pp))
{
printf("%s\n", buf2);
fgets(buf, sizeof(buf2), pp);
}
pclose(pp);
I must reiterate Jason's point, executing another program like ls from within
the MUD is really slow and kind of messy, and some people are pretty anal
about wasting cycles.
One thing to remember is that all of the shell programs like ls are
themselves written in C, so you can usually find the code out there to do
what you want without the problems inherent in calling outside programs.
--Palrich.