gcc - Open / lunch mutiple pdf file at ones with C? -


i trying lean c.

i has make lille program / daemon.

the meaning .pdf in 'taskfolder'-->(rootfolder).

will open / lunch on start-up via 'evince'.

do need lead abort threading or there better way this?

i has try system("envice 1.pdf && envice 2.pdf ...");

but still open pdf files 1 @ time.

the code this.

#include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h>  #define rootfolder ((const unsigned char *)"/home/myusername/taskfolder/") #define luncherapp ((const unsigned char *)"evince ")  int main() {     dir *d;     struct dirent *dir;     char *ext;     d = opendir(rootfolder);     if(d)     {         int i=0;         char *tmp;         while((dir = readdir(d)) != null)         {             ext = strchr(dir->d_name, '.');             if((ext != null) && (ext != 0) && (strcmp(strchr(ext ,'.'), ".pdf") == 0))             {                 tmp = malloc(strlen(luncherapp) + strlen(rootfolder) + strlen(dir->d_name) + 1);                 strcat(tmp, luncherapp);                 strcat(tmp, rootfolder);                 strcat(tmp, dir->d_name);                 printf("pdf== %s\n", tmp);                 system(tmp);// <-- 'evince ~/taskfolder/filename.pdf'                 free(tmp);                 ++i;             }         }         closedir(d);     }     return 0; } 

update-code:

#include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h>  #define app ((const unsigned char *)"evince") #define rootfolder ((const unsigned char *)"./") int main() {     dir *d;     struct dirent *dir;     char *ext;     d = opendir(rootfolder);     if(d)     {         char *cmd = malloc(1);         strcat(cmd, app);         while((dir = readdir(d)) != null)         {             ext = strchr(dir->d_name, '.');             if((ext != null) && (ext != 0) && (strcmp(ext, ".pdf") == 0))             {                 cmd = realloc(cmd, strlen(cmd)+strlen(rootfolder)+strlen(dir->d_name)+1);                 strcat(cmd, " ");                 strcat(cmd, rootfolder);                 strcat(cmd, dir->d_name);             }         }         closedir(d);         printf("\nrun:\n%s\n", cmd);         system(cmd);         free(cmd);     }     return 0; } 

i not familiar envice, command:

"envice 1.pdf && envice 2.pdf ..."  

will execute envice 1 time each file. don't think that's intended. think intended execute envice 1 time files on command line. if correct, need leave out && , format this:

"envice 1.pdf 2.pdf ..."  

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -