If I want to create forder "3" like this c:\3\
How to write program to do that?
Printable View
If I want to create forder "3" like this c:\3\
How to write program to do that?
There are a few different ways, I think i remember a function in a windows header somewhere that did it (CreateDir or something I think) but you could always use
(if mkdir is the right command for making a folder in windows, I forget).Code:#include <stdlib.h>
..
system("mkdir foldername");
PS: You would do better to search windows header files though anyway, I'd start at wincon.h, I think its in there.
~ Paul
I think there are standard routines also available for creating folders.
Try searching the documentation of your compiler.
>I think there are standard routines also available for creating folders.
No, but there are usually non-standard compiler libraries that do this. However, it appears that you're using Windows, so you can turn to the Win32 API with the CreateDirectory function:
-PreludeCode:#include <iostream>
#include <string>
#include <windows.h>
int main()
{
std::string folder_name;
std::cout<<"Enter a folder name to create: ";
std::getline ( std::cin, folder_name );
if ( CreateDirectory ( folder_name.c_str(), NULL ) != 0 )
std::cout<<"Folder created successfully"<<std::endl;
}