Remove characters from a string, remove characters from a string array, and remove an array.

Source: Internet
Author: User

Remove characters from a string, remove characters from a string array, and remove an array.


/**
* Remove a SASL mechanic from the list to be used.
*
* @ Param mech the SASL mechanic to be removed
*/
Public static void removeSaslMech (String mech ){
If (defamemechs. contains (mech )){
DefaultMechs. remove (mech );
}
}


/**
* Remove a Collection of SASL mechanisms to the list to be used.
*
* @ Param mechs the Collection of SASL mechanisms to be removed
*/
Public static void removeSaslMechs (Collection <String> mechs ){
For (String mech: mechs ){
RemoveSaslMech (mech );
}
}
Use an array or pointer as a function parameter to delete non-lowercase letters in the string. In the main function, input strings and output the strings before and after the characters are deleted.

# Include <stdio. h>
# Include <ctype. h>

Void DeleteLower (char acstr [], int iCount)
{
Int iTemp = 0;
Char acTemp [30] = {0 };

Printf ("your input string: % s \ n", acstr );

For (int I = 0; I <iCount; ++ I)
{
If (! (Islower (acstr [I])
{
AcTemp [iTemp] = acstr [I];
ITemp ++;
}
}

Printf ("deleted string: % s \ n", acTemp );

}

Void main ()
{
Printf ("enter a string (less than 30) \ n ");

Char acstr [30] = {0 };

Scanf ("% s", acstr );

DeleteLower (acstr, 30 );

}
 
How to delete a character from a string in the C character array

For example:
# Include <stdio. h>
# Include <string. h>

Int main ()
{
Char a [10] = {"1234567890 "};
Int I, j;
For (I = 0; I <strlen (a); I ++)
{
If (a [I] = '7 ')
{
For (j = I; j <strlen (a)-1; j ++)
{
A [j] = a [j + 1];
}
A [j] = '\ 0 ';
Break;
}
}
For (I = 0; I <strlen (a); I ++)
{
Printf ("% c", a [I]);
}
Printf ("\ n ");
Return 0;
}

// I hope the landlord can understand that I have directly typed the code above. I don't know if the code can be compiled. Sorry, no compiler (in Internet cafes)

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.