Subject: Re: Unable to C-compile simple program
To: Ib-Michael Martinsen <imm@nethotel.dk>
From: Patrick Welche <prlw1@cam.ac.uk>
List: port-arm32
Date: 08/02/1998 10:35:20
Ib-Michael Martinsen wrote:
> 
> Hi there,
> 
> Can anybody explain this oddity?
> 
> When I try to compile the following program:
> 
> #include    <stdio.h>
> #include    <dirent.h>

How about

  #include <stdio.h>
  #include <sys/types.h>
  #include <sys/dir.h>

> void syntax(char *program) {
> 
>     fprintf(stderr, "Syntax: %s [<directory>]\n", program);
> }
> 
> 
> int main(int argc, char *argv[]) {
> 
> DIR     *dp;
> dirent  *de;

This needs to read

struct dirent *de;

>     if (argc > 2) {
>         syntax(argv[0]);
>         exit(0);
>     }
>     if (argc == 1)
>         dp = opendir(".");
>     else
>         dp = opendir(argv[1]);
>     while ((de = readdir(dp)) != NULL) {
>         printf("%s\n", de->d_name);
>     }
>     closedir(dp);
>     return 0;
> }

Cheers,

Patrick