User created folders

This is a discussion on User created folders within the C++ Programming forums, part of the General Programming Boards category; Hi, Im kind of new to c++ and need a little help. Im trying to make my program allow the ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    3

    User created folders

    Hi, Im kind of new to c++ and need a little help.
    Im trying to make my program allow the user to enter a name and then create a folder using that name.

    I tried

    Code:
    string name;
    cout << "please enter a name... " << endl;
    cin >> name;
    system (""mkdir " << name");
    but it gives an error on the system line, please help.

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,751
    System() has gotten awfully popular lately and for bad, bad reasons. You should really search for different ways to do this.

    You could download and use a library, for instance.
    http://www.informit.com/guides/conte...eqNum=245&rl=1

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    3
    whats wrong with the system() comand

  4. #4
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,751
    You can read this article to find out. It focuses on using system to pause the program, but the article will show you what's wrong with system entirely.

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    3
    I really dont understand that much about c++ so using a new library is kind of confusing. Can anyone help explain how to let a user pick the folder name without a new library. Im sure it would use the system("mkdir") command.

  6. #6
    Registered User
    Join Date
    Mar 2005
    Posts
    140
    I also suggest you don't use system, but of course it is possible.

    Code:
        string name;
        string cmd;
    
        cout << "please enter a name... " << endl;
        cin >> name;
    
        cmd = "mkdir " + name;
    
        system(cmd.c_str());

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,750
    How about something radical, like maybe the mkdir() API call instead?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help managing user input
    By JayDiddums10 in forum C Programming
    Replies: 2
    Last Post: 11-19-2006, 05:01 PM
  2. pass error before char
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-26-2006, 12:00 PM
  3. ~ User Input script help~
    By indy in forum C Programming
    Replies: 4
    Last Post: 12-02-2003, 06:01 AM
  4. user created header files
    By MedicKth in forum C++ Programming
    Replies: 6
    Last Post: 09-20-2003, 01:36 PM
  5. Stopping a user from typeing.
    By knave in forum C++ Programming
    Replies: 4
    Last Post: 09-10-2001, 01:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21