----- Original Message -----
Sent: Saturday, February 15, 2003 8:35
PM
Subject: Reading a file???
Hi,
I've got the following code that loads every
file in a directory and is then meant to read each file into a variable where
a few things are done with it:
void
readfromfile()
{
FILE *fr;
DIR *dir;
struct
dirent *ent;
gchar temp2;
dir =
opendir("/home/nuser/pro1/data");
while ((ent = readdir(dir)) !=
NULL)
{
if(!((strncmp(".",ent->d_name,1) ==
0)))
{
//WE'LL START READING A FILE
HERE...
strcpy(temp2,ent->d_name);
// <- It crashes here...possibly the
'ent->d_name'???
strcat("/home/nuser/pro1/data",temp2);
fr = fopen(temp2,"r");
if(fr)
{
while
(!feof(fr))
{
char
temp[100];
(fgets(temp,99,fr);
printf(temp);
}
fclose(fr);
}
else
{
fr
= NULL;
printf("Failed to open
file");
}
}
else
{
printf("File
skipped");
}
}
}
Can anybody lend a hand please?
Thanks,
Uni