help:File Processing

This is a discussion on help:File Processing within the C Programming forums, part of the General Programming Boards category; Hello,everyone.I am new to C and I met some problems in processing files. I have a bunch of files in ...

  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,046
    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
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    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,046
    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, 03: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21