× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have now, gotten past reading all the files in a directory, and placing
the data into fields...  I now want to write to a externally described
database file...

>From the archives I have seen, the #Pragma mapinc, OR the GENCSRC to include
external files..

Whats the best way?  The text I have seen recommends GENCSRC for versions
5.1 and higher.  But I like the #pragma idea more...

Any thoughs, were at version 5.2

Thanks, tim



> -----Original Message-----
> From: c400-l-bounces@xxxxxxxxxxxx [SMTP:c400-l-bounces@xxxxxxxxxxxx] On
> Behalf Of James Rich
> Sent: Wednesday, September 29, 2004 3:23 PM
> To:   C programming iSeries / AS400
> Subject:      Re: [C400-L] ifs help
> 
> On Tue, 28 Sep 2004, Hatzenbeler, Tim wrote:
> 
> > I'm trying to use our C compiler for the 1st time...
> >
> > I would like to write a program, to read all the 'filenames' in a single
> > directory in the IFS, and then open each file, I I would like to parse
> it,
> > and place the contents in a 'Table' I was wondering if any body has any
> code
> > snippets they sould share to get my feet wet...  I haven't touched 'C'
> code
> > in 10 years sine the Amiga.
> 
> Sorry to take so long to respond.  Here is some code to get you started:
> 
> /* This program demonstrates using C to change directories
>   * and list the files in a directory
>   */
> 
> #include <stdio.h>
> #include <string.h>
> #include <unistd.h>
> #include <sys/types.h>
> #include <dirent.h>
> 
> /* Define this to be the directory you want to change to */
> #define NEW_DIR "/home"
> 
> int
> main ()
> {
>    char dir[1024];
>    DIR *directory;
>    struct dirent *entries;
> 
>    /* First we demonstrate how to get the current directory
>     * Notice that getcwd() returns a *char and dir also contains
>     * the name of the directory
>     */
>    printf ("pwd = %s\n", getcwd (dir, sizeof (dir)));
>    printf ("dir = %s\n", dir);
> 
>    /* Change to NEW_DIR and check for errors */
>    if (chdir (NEW_DIR) != 0)
>      {
>        printf ("Eek! cannot chdir to %s\n", NEW_DIR);
>        return (-1);
>      }
> 
>    /* Here we erase dir since we are going to call getcwd() again
>     * to prove that chdir() worked.
>     */
> /*bzero (dir, sizeof (dir));*/
>    printf ("The files in %s are:\n", getcwd (dir, sizeof (dir)));
> 
>    /* Now open the directory we just changed to. */
>    directory = opendir (NEW_DIR);
> 
>    /* Use a loop to print out all the files in the directory. */
>    while ((entries = readdir (directory)) != NULL)
>      {
>        printf ("%s\n", entries->d_name);
>      }
> 
>    /* Don't forget to close! */
>    closedir (directory);
> 
>    /* Done */
>    return (0);
> }
> 
> James Rich
> 
> Vs lbh cynl n Zvpebfsg PQ  onpxjneqf, lbh pna urne fngnavp zrffntrf. Ohg
> rira jbefr, vs lbh cynl vg sbejneq, vg vafgnyyf gurve fbsgjner!
>          -- Fcbgvphf ba /.
> _______________________________________________
> This is the C programming iSeries / AS400 (C400-L) mailing list
> To post a message email: C400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/c400-l
> or email: C400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/c400-l.
> 
This e-mail message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential or privileged
information.  Any unauthorized review, use, disclosure or distribution is
prohibited.  If you are not the intended recipient, please contact the
sender by reply e-mail and destroy the message.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.