Mail Archives: djgpp/1994/02/08/09:09:11
Hello,
I've written a procedure which lists the files in the
current directory but met a problem : when the current
directory have some sub-directory the procedure stop
and the message "Segmentation violation pointer" is printed.
The same code run well under UNIX system so I don't understand
where the problem come from ( I'm using DJGPP 1.10 whith a
386 SX under MS-DOS 5.0 )
I've included some of the code below :
/*-------------------------------------------
#include<stdio.h>
#include<dirent.h>
void List_file()
{
DIR *dirp;
FILE *pf;
struct dirent *dp;
char nom_fichier[80],ligne[80];
dirp = opendir(".");
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
{
--> stop at this line: sprintf(nom_fichier,"%s",dp->d_name);
if (nom_fichier[0]!='.')
{
pf = fopen(nom_fichier,"r");
fscanf(pf,"%s",ligne);
....
/*----------------------------------------------
Thanks in advance for any help.
Gilles GUYOT ( gguyot AT dedale DOT inria DOT fr )
- Raw text -