Enter two strings, removing all the characters from the second string from the first string.

Source: Internet
Author: User
Tags first string
Remove a specific character from a string
The input "They is students." and "Aeiou" is removed after the first string becomes thy R stdnts.

"String Hash" is also used in the subject.


#include <iostream> #include <cstring>char * string_del_characters (char * const SRC, const char * const DEST) { int destlen = strlen (dest); int hash_table[256] = {0}; char * p = src; int index = 0; for (int i = 0; i < Destlen; i++) { hash_table[(int) dest[i]] = 1; } while (*p! = ') } { if (0 = = hash_table[(int) *p]) { src[index++] = *p; } p++; } Src[index] = ' + '; return SRC;} int main (int argc, char * * argv) { char src[] = "They is students."; Char dest[] = "Aeiou"; char * pResult = string_del_characters (src, dest); Std::cout << pResult << Std::endl;}

  

Enter two strings, removing all the characters from the second string from the first string.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.