Remove a character from a character array

Source: Internet
Author: User

/* Implement the function of the program: remove characters stored in C from the character array S. */

#include <stdio.h>intMainintargcConst Char*argv[]) {    Chars[ the],c; printf ("Please enter a string \ n");        Gets (s); printf ("Please enter a character \ n"); scanf ("%c",&c); //Traversing Strings     for(inti =0; S[i]! =' /'; i++) {        if(S[i] = =c) {//if the corresponding character of the small label I equals C, then the character moves forward one//Note: I can no longer be used here because the completion of the loop causes the value of I to be the subscript for the last character of the string             for(intj = i; S[J]! =' /'; J + +) {S[j]= s[j+1]; }}} printf ("%s\n", s); return 0; }

Remove a character from a character array

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.