samedi 30 janvier 2021

read a file from the directory with c program

I want to read each file one by one from a folder in C. the below program keeps printing "." and does not aalow me to access the images. how can i handle the "." and ".." files the following is my program

 while (1) {
    folder = opendir("./result_img/");
    //char str1[100] = "./result_img/";
    while( (entry=readdir(folder)) != NULL)
    
    {
    closedir(folder);
    folder = opendir("./result_img/");
    char str1[100] = "./result_img/";
    if((strcmp(entry->d_name,".")==0 || strcmp(entry->d_name,"..")==0 || (entry->d_name) == '.' ) || (strcmp(entry->d_name,"Server_v1.py")==0))
    {
     printf("issue %s",entry->d_name);
     sleep(0.5);
     continue;
    }
//further processing of each image here
}
}

Aucun commentaire:

Enregistrer un commentaire