Like Tree1Likes
  • 1 Post By EVOEx

appending a wildcard to the end of a string

This is a discussion on appending a wildcard to the end of a string within the C++ Programming forums, part of the General Programming Boards category; cin >> buf2; // with a /* at the end I need to put a /* at the end of ...

  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.
    Elysia likes this.

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, 06:58 PM
  2. Appending to a C string
    By Sharke in forum C Programming
    Replies: 2
    Last Post: 04-28-2009, 01:23 AM
  3. Wildcard string matching
    By JizJizJiz in forum C++ Programming
    Replies: 3
    Last Post: 06-29-2006, 10:54 AM
  4. wildcard case insensitive string compare
    By lawina in forum C Programming
    Replies: 3
    Last Post: 06-13-2006, 04:27 AM
  5. String appending
    By larry in forum C++ Programming
    Replies: 9
    Last Post: 09-30-2001, 05:34 AM

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