C
chiara
Hi!
This is a piece of a code I wrote. It was perfectly working but now it
is giving me some problems I can not understand.
I scan a directory (ss_data) and I count its alaments. then I print the
name of each file in the directory before opening it.Even if the names
of the files are stored correctly in the memory the program prints the
letter 'E'(the files are named differently,
e.g.traind05c1__a.1.1.1.3.fasta). The program correctly opens the files
but it does not print the names. Anybody can help?
Thank you in advance,
Chiara
#include <string.h>
#include <stdio.h>
#include <dir.h>
#include <dirent.h>
#include <stdlib.h>
#include <alloc.h>
#include <math.h>
char **strings,*line;
int n_seq=0;
int max_line_len = 1024;
char **Amm,**Pss;
int** amm_comp,*y_class,*y_fold,**ss_descriptor;
char** SS;
int** L,**range;
int n_files,n_el,max_length;
void generateSeq(int max_l,char* seq,int seq_len);
char* readline(FILE *input);
void scandir(char *dirname);
void analyzePss(char* pss,int ind);
int SearchSequence(char* seq, char* in);
int SearchRange(int* seq,int l, int low, int up);
void scandir(char *dirname)
{
DIR *dir;
FILE*fp;
char s[MAXPATH],amm,pss;
struct dirent *ent;
float pC, pH,pE;
int index,i,h,k=0,max_l,n=0;
dirname="ss_data";
if ((dir = opendir(dirname)) == NULL)
{
perror("Unable to open directory");
exit(1);
}
while ((ent = readdir(dir)) != NULL) //reads the directory counting
the number of files
{
if(strlen(ent->d_name)>5)
n_files++;
}
...
rewinddir(dir);
h=0;
while ((ent = readdir(dir)) != NULL)//reads the name of each file in
the directory
{
if(strlen(ent->d_name)>5)
{
printf("%d:%s\n",h,ent->d_name);
.....
...
This is a piece of a code I wrote. It was perfectly working but now it
is giving me some problems I can not understand.
I scan a directory (ss_data) and I count its alaments. then I print the
name of each file in the directory before opening it.Even if the names
of the files are stored correctly in the memory the program prints the
letter 'E'(the files are named differently,
e.g.traind05c1__a.1.1.1.3.fasta). The program correctly opens the files
but it does not print the names. Anybody can help?
Thank you in advance,
Chiara
#include <string.h>
#include <stdio.h>
#include <dir.h>
#include <dirent.h>
#include <stdlib.h>
#include <alloc.h>
#include <math.h>
char **strings,*line;
int n_seq=0;
int max_line_len = 1024;
char **Amm,**Pss;
int** amm_comp,*y_class,*y_fold,**ss_descriptor;
char** SS;
int** L,**range;
int n_files,n_el,max_length;
void generateSeq(int max_l,char* seq,int seq_len);
char* readline(FILE *input);
void scandir(char *dirname);
void analyzePss(char* pss,int ind);
int SearchSequence(char* seq, char* in);
int SearchRange(int* seq,int l, int low, int up);
void scandir(char *dirname)
{
DIR *dir;
FILE*fp;
char s[MAXPATH],amm,pss;
struct dirent *ent;
float pC, pH,pE;
int index,i,h,k=0,max_l,n=0;
dirname="ss_data";
if ((dir = opendir(dirname)) == NULL)
{
perror("Unable to open directory");
exit(1);
}
while ((ent = readdir(dir)) != NULL) //reads the directory counting
the number of files
{
if(strlen(ent->d_name)>5)
n_files++;
}
...
rewinddir(dir);
h=0;
while ((ent = readdir(dir)) != NULL)//reads the name of each file in
the directory
{
if(strlen(ent->d_name)>5)
{
printf("%d:%s\n",h,ent->d_name);
.....
...