C + + Creates a directory under Windows

Source: Internet
Author: User

#include <direct.h>#include<stdlib.h>#include<stdio.h>intMainvoid ){    if(_mkdir ("\\testtmp") ==0) {printf ("Directory ' \\testtmp ' was successfully created\n" ); System ("dir \\testtmp" ); if(_rmdir ("\\testtmp") ==0) printf ("Directory ' \\testtmp ' was successfully removed\n"  ); Elseprintf ("problem removing directory ' \\testtmp ' \ n" ); }    Elseprintf ("problem creating directory ' \\testtmp ' \ n" );    GetChar (); return 0;}

It is added by default in the current work disk. _mkdir run failure will return-1 and set errno

Eexist

The path was not created because the path name already exists. Same name as file, path, or drive

ENOENT

Path does not exist

For example: The program works in the D-disk actual directory is "D:\\testtemp"

_rmdir () similarly

C + + Creates a directory under Windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.