findfirst

This is a discussion on findfirst within the C Programming forums, part of the General Programming Boards category; Hi fellas, I wrote this C program to alter some stuff from a .stf file and save it in a ...

  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
    Attached Files Attached Files

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    Both findfirst() and findnext() are not part of the C standard library. Where did you hear of them?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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:
    Handling multiple input files from command line

    --
    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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    What university is this, so I can be sure to avoid it in the future?

  12. #12
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  13. #13
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    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, 10:42 AM
  2. getting filenames
    By madsmile in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2002, 01:40 PM
  3. findfirst, findnext question...
    By Brian in forum Windows Programming
    Replies: 2
    Last Post: 01-27-2002, 08: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

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