www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/02/08/09:09:11

Date: Tue, 8 Feb 1994 14:12:13 +0100
From: Gilles Guyot <Gilles DOT Guyot AT sophia DOT inria DOT fr>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Pb. while reading directories

  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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019