Thread: help:File Processing

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    5

    Question help:File Processing

    Hello,everyone.I am new to C and I met some problems in processing files.
    I have a bunch of files in a directory,let's say directory A,I want to write a function to process all the files in the directory,like function B.
    so I try to use fopen to open every file and then handle it,but since fopen can only accept files' names that has been assigned and the files in directory A are named differently,how can I make it?

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Check the FAQ. It has an entry about this.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by dwks View Post
    Check the FAQ. It has an entry about this.
    Or, depending on your requirements, you can punt and specify that the user must list all the filenames on the command line (or some other way). Then the user just uses '*' to indicate all the files in a given directory. Unless you're on some stupid OS where the shell doesn't do glob expansion for you
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Registered User
    Join Date
    Dec 2008
    Posts
    5
    thanks,though a bit general,I will check it.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Yeah, sorry for my reply. I had approximately twelve seconds left on CBoard before I had to go.

    Here's the FAQ entry I was referring to: http://faq.cprogramming.com/cgi-bin/...&id=1044780608
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reentrant Message Processing (WndProc)
    By phantomotap in forum Windows Programming
    Replies: 7
    Last Post: 04-28-2009, 10:44 AM
  2. What types of files can C++ file processing handle?
    By darsunt in forum C++ Programming
    Replies: 9
    Last Post: 10-28-2008, 11:33 AM
  3. Sub Array Processing
    By GCNDoug in forum C++ Programming
    Replies: 8
    Last Post: 11-28-2007, 04:41 PM
  4. Using a lot of processing time!
    By nickname_changed in forum C++ Programming
    Replies: 0
    Last Post: 09-25-2003, 03:44 AM
  5. file writing crashes
    By test in forum C Programming
    Replies: 25
    Last Post: 08-13-2002, 08:44 AM