Thread: findfirst

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

    findfirst

    Hi fellas,
    I wrote this C program to alter some stuff from a .stf file and save it in a new file.
    In my current program one has to manually enter the name of the input file. Now i wanted to build on the program to automatically get all the files in a folder to be converted at one shot without entering the name manually.

    I fugured out that the way to do it is by using findfirst() & then findnext() in C.
    However i cannot get the details how to use the findfirst() & findnext() functions.
    If any one of you could help it would be great.
    Thank you

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    And how does the block of code written by someone else 10+ years ago have anything to do with your question?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Both findfirst() and findnext() are not part of the C standard library. Where did you hear of them?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Aug 2008
    Posts
    5
    findfirst & findnext is from io.h
    & salem i was given this code from one dept at our university to work on it
    i have searched the msdn site but if there was an example of use of findfirst somewhere that wouls help a lot as i am kinda new to programming

  6. #6
    Registered User
    Join Date
    Aug 2008
    Posts
    5
    also is there any other way to read the files in a folder with c with a dos environment

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by jersey_gal View Post
    also is there any other way to read the files in a folder with c with a dos environment
    You really want in a DOS environment (as in Visual Studio V1.52c type compiler), or just a console app using a compiler produced in the latter part thus far in this millenium?

    There are several ways, but it's pretty much the same. Of course, there was a thread the other day that solves the problem of "myprog *.ext" type arguments - so you could use argc/argv to get a list of all the files. I will edit this post when I have found the thread.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    They do know how out of date DOS is right?

    Which department was it, Egyptian history?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    As there was another post after mine, here's the thread about how to resolve wildcards in arguments:
    http://cboard.cprogramming.com/showthread.php?t=106437

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Aug 2008
    Posts
    5
    even if i get it working on windows that should be okay with them but my prog is to learn how to read the files

  11. #11
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    What university is this, so I can be sure to avoid it in the future?

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Apparently, it's Rutgers. Who I would have thought would have been more "with it".

    And here's me thinking it was only the entire Indian education system that was stuck in the past.

    Now this news article is making a lot more sense now.
    http://news.bbc.co.uk/1/hi/technology/7571211.stm
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  13. #13
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Hmmm, and my cousin is at Rutgers studying aerospace engineering, I'll have to ask him about the quality of the program

    Giving the benefit of the doubt, it looks like the code might be from some biomedical engineering project; I suppose it could've just been thrown over the wall by some professor in that program as an example?

    I don't know...at the beginning jersey_gal said she wrote the code, so...

  14. #14
    Registered User
    Join Date
    Aug 2008
    Posts
    5
    this program was did something else before......i used the same structure to read the file

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Aside from advice already given, the FAQ has some help: http://faq.cprogramming.com/cgi-bin/...&id=1044780608

    If you are still unclear on the subject, you may want to post a more concise question.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. findfirst
    By Flip in forum C++ Programming
    Replies: 3
    Last Post: 01-01-2006, 11:42 AM
  2. getting filenames
    By madsmile in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2002, 02:40 PM
  3. findfirst, findnext question...
    By Brian in forum Windows Programming
    Replies: 2
    Last Post: 01-27-2002, 09:28 AM
  4. findfirst, findnext ??
    By Jamazon in forum C++ Programming
    Replies: 1
    Last Post: 10-24-2001, 12:48 PM
  5. findfirst, findnext.
    By Jamazon in forum C++ Programming
    Replies: 1
    Last Post: 10-22-2001, 10:59 PM