Hi all

My bro rang me up, and for some reason he asked me to make him a "simple" program that creates a folder and the user enters the name for that folder then it acopies pre set files in to that new folder.
The folder will be created in the same directory as the program and all the files for moving will also be in the same directory as the program.
For example I called the folder house and then it would look for a file in the same directory as the program and house folder called
blank contact log.doc
and copy the .doc folder into the house folder.
I am learning C so I want to try and code this in C so can anyone give me some help please?
I have googled create directory in C but all i get is C#.

Many thanks

HLA91

Recommended Answers

All 3 Replies

What part did you not understand of the answer over here?

I couldnt understand the createdirectory function I just became really confused with the code shown , can someone please explain it a bit more clearly?
Also isnt that code for the win api GUI thing? Would it be applicable to console based programs?

It is not my place to lecture you here, however it is annoying to the people that helps in diverse forums to see the same person asking the same question across boards, especially when you could have continued inquiring about what you didn't understand at the first post.
I am going to point to you to the same code sample, in case you missed it. Look inside for these lines of code:

if (!CreateDirectory(argv[1], NULL))

That's to make the directory

if (CopyFile(FileData.cFileName, szNewPath, FALSE))

That's to copy the file.

>>Also isnt that code for the win api GUI thing? Would it be applicable to console based programs?

These are Windows API functions, that allow you to do programming in the MS Windows Operating System as efficiently as the designers of the system intended. There's some ways that you could achieve the same result using standard C functions, but the API will do it more efficiently. Or that's the idea behind. You can program for a GUI or for a shell command line window.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.