Thread: appending a wildcard to the end of a string

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    13

    appending a wildcard to the end of a string

    cin >> buf2; // with a /* at the end

    I need to put a /* at the end of a cin input. how do i do this?


    Its for a directory...I enter c:/users and the i need to append /* to the end to get c:/users/*

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    i think i can use STRCAT

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    13
    nevermind i got it with s

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    You definitely should NOT be using strcat. You should be reading in a C++ string (std::string), not a C-string (char buf[...]). After that, you can simply add it by saying either:
    Code:
    buf2 += '*';
    buf2.append('*');
    Though in this case, you should probably also check to make sure the last character is a '/' if that's a requirement, and if not, append that as well.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Search WILDCARD characer in STRING!!!!
    By slowprogrammer in forum C Programming
    Replies: 3
    Last Post: 05-25-2010, 05:58 PM
  2. Appending to a C string
    By Sharke in forum C Programming
    Replies: 2
    Last Post: 04-28-2009, 12:23 AM
  3. Wildcard string matching
    By JizJizJiz in forum C++ Programming
    Replies: 3
    Last Post: 06-29-2006, 09:54 AM
  4. wildcard case insensitive string compare
    By lawina in forum C Programming
    Replies: 3
    Last Post: 06-13-2006, 03:27 AM
  5. String appending
    By larry in forum C++ Programming
    Replies: 9
    Last Post: 09-30-2001, 04:34 AM