| | |
code to use all .htm files in a directory
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2004
Posts: 29
Reputation:
Solved Threads: 0
hi.
question 1:
i am writing a small C script to convert files to another format.
in this case i need my script to use all files in a directory that have extension .htm - how can i do this?
the user will manually specify the directory path but then i want the software to find all .htm files and take their contents to paste them in another file
question 2:
after the user wrote the directory's path (eg. /home/frank/mywebsite) it will save it in a char variable.
when i need to open a certain file I have to specify the path myself, like this
but now can i do this
?
question 1:
i am writing a small C script to convert files to another format.
in this case i need my script to use all files in a directory that have extension .htm - how can i do this?
the user will manually specify the directory path but then i want the software to find all .htm files and take their contents to paste them in another file
question 2:
after the user wrote the directory's path (eg. /home/frank/mywebsite) it will save it in a char variable.
when i need to open a certain file I have to specify the path myself, like this
C Syntax (Toggle Plain Text)
fp = fopen("/var/tmp/string.txt", "r")
but now can i do this
C Syntax (Toggle Plain Text)
fp = fopen("user_path/some_file.htm", "r")
?
>i need my script to use all files in a directory
You can search a directory with opendir and readdir and closedir. Check your man pages for details.
>but now can i do this
You need to build the path string manually:
You can search a directory with opendir and readdir and closedir. Check your man pages for details.
>but now can i do this
You need to build the path string manually:
C Syntax (Toggle Plain Text)
char user_path[] = "user_path"; char filename[] = "some_file"; char full_path[BUFSIZ]; sprintf ( full_path, "%s/%s.htm", user_path, filename ); fp = fopen ( full_path, "r" );
I'm here to prove you wrong.
![]() |
Similar Threads
- Listing files in a directory (C++)
- read all files in a directory (C++)
- .htaccess File Problems (*nix Software)
- To open and close in turn all the files in a directory (C++)
- Have a problem with centering "jpg" files (HTML and CSS)
- List files from a directory (C)
- Script use command mail (Shell Scripting)
Other Threads in the C Forum
- Previous Thread: Getting the time from GetSystemTime
- Next Thread: File I/O Help
| Thread Tools | Search this Thread |
* ansi api append array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() dynamic execv fflush file floatingpointvalidation fork forloop frequency function getlogicaldrivestrin givemetehcodez grade graphics gtkwinlinux histogram homework i/o ide inches include infiniteloop initialization input intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft multi mysql oddnumber open opendocumentformat openwebfoundation overwrite pdf pointer pointers posix power program programming pyramidusingturboccodes radix read recursion recv recvblocked reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string strings suggestions test testautomation threads unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






