”工欲善其事,必先利其器。“—孔子《论语.录灵公》
首页 > 编程 > 挤压以从字符串中删除字符。

挤压以从字符串中删除字符。

发布于2024-08-01
浏览:949

squeeze to remove chars from string.

https://www.learntosolveit.com/ 是一个使用现代工具使用 K&R 书籍学习 C 编程的配套网站。这篇文章讨论了书中的练习和主题。

/**
 * Exercise 2.4
 *
 * Let us write a version of squeeze(s1,s2) that deletes each
 * character in the string 1 that matches any character in the string s2.
 * Utilize user defined function mgetline to input the strings.
 * Don't use any standard library string manipulation function.
 *
 **/

#include 

#define MAXLINE 1000

int mgetline(char s[], int lim);

void squeeze(char s1[], const char s2[]);

int main(void) {
    char s1[MAXLINE], s2[MAXLINE];
    mgetline(s1, MAXLINE);
    mgetline(s2, MAXLINE);

    squeeze(s1, s2);

    printf("\n%s\n", s1);

    return 0;
}

int mgetline(char s[], int lim) {
    int i, c;

    for (i = 0; i 



遵循这篇文章中该程序的直观解释 - https://www.learntosolveit.com/cprogramming/chapter2/ex_2.4_squeezess

版本声明 本文转载于:https://dev.to/orsenthil/squeeze-to-remove-chars-from-string-4n01如有侵犯,请联系[email protected]删除
最新教程 更多>

免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。

Copyright© 2022 湘ICP备2022001581号-3