Solved

Create a folder monthly

Posted on 1998-07-07
1
255 Views
Last Modified: 2010-04-01
Hi,
  I want to create a folder format by "mm-yy" monthly?
The first thing, I want to check the folder exist or not.
If the folder is not exist then create the folder for the current month.  What's the best way I can do?
Thanks!!
J Chen
0
Comment
Question by:jpchen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 1167343

#include <stdio.h>
#include <time.h>
#include <direct.h>
#include <errno.h>

extern int errno;

int main(int, char*)
{
      time_t t;
      time(&t);
      tm* ptm = localtime(&t);

      char sz[100];
      sprintf(sz, "%2.2d-%2.2d", ptm->tm_mon + 1, ptm->tm_year);

      int nRet = mkdir(sz);
      if (nRet == 0)
            puts("Created successfully.");
      else
            if (errno == EEXIST)
                  puts("Already exists!");

      return nRet;
}


0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question