相关疑难解决方法(0)

如何在c中剪切一部分字符串?

我正在试图弄清楚如何在C中切割一部分字符串.例如,你有这个字符串"狗死了,因为一辆车在过马路时撞到了他"一个函数如何制作句子"a过马路时撞到他的车"还是"一辆车撞到了他"

你如何使用C的库(或/和)自定义函数来解决这个问题?

好吧,我没有主要代码,但这将是这个实验的结构

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include "display_usage.c"/*If the user enters wrong arguments it will tell them how it should be */


void cut( const char *file, int option, int first, int last );


int main(int argc, char *argv[] ) {
FILE *fp;
    char ch;
    fp = fopen("test.txt", "r"); // Open file in Read mode

    while (ch!=EOF) {
        ch = fgetc(fp); // Read a Character

        printf("%c", ch);
    }
    fclose(fp); // Close …
Run Code Online (Sandbox Code Playgroud)

c string cut

8
推荐指数
2
解决办法
6万
查看次数

标签 统计

c ×1

cut ×1

string ×1