
January 20th, 2006, 05:23 AM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 9
Time spent in forums: 4 h 54 m 28 sec
Reputation Power: 0
|
|
|
What's wrong with my func - popen fgets...
Using Linux/C - can't get the following to work...beginner please help
void Func_Get_Image()
{
int Current_Image_Num = 1;
char Var_Get_Image[MAX_DIR_LENGTH] = { 0x0 };
sprintf( Var_Get_Image, "find $HOME/Pictures -iregex '.*\.\(gif\|jpg\|jpeg\|bmp\|png\||tif\||tiff\||svg\)' | sed %d'q;d'", Current_Image_Num);
FILE *in=popen("Var_Get_Image","r");
char tmp[MAX_DIR_LENGTH]={0x0};
while(fgets(tmp,sizeof(tmp),in))
printf("%s",tmp);
pclose(in);
}
This compiles...but Var_Get_Image is being sent as the command rather than the contents of Var_Get_Image (find $HOME/Pictures -iregex '.*\.\(gif\|jpg\|jpeg\|bmp\|png\||tif\||tiff\||svg\)' | sed %d'q;d')
|