?
Solved

Create a folder monthly

Posted on 1998-07-07
1
Medium Priority
?
266 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 300 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

777 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