多语言展示
当前在线:355今日阅读:23今日分享:25

c语言怎样截取字符串

今天小编给大家带来的是c语言怎样截取字符串,希望能帮助到大家!
工具/原料
1

PC

2

C语言

方法/步骤
1

直接给大家代码吧:#include#include#includevoid print(char s[],int n,int m){    int k;    int i;    char *p;    k=strlen(s);    p = s;

2

for(i=n-1;i

3

题目要调用这个函数:viod substr(char *source,int start,intlength,char *dest);// cscs.cpp : Defines the entry point for the console application.// #include 'stdafx.h'#include#include#includevoid substr(char *source,int start,int length,char *dest);int main(){

4

char a[20],b[20],*p;    int n,x,i;    printf('how long:');    scanf('%d',&n);    printf('where:');    scanf('%d',&x);    getchar();    printf('input words:');    gets(a);    p = a;    substr(p,x,n,b);    return 0;}

5

void substr(char *source,int start,int length,char *dest){    int k;    int i;    int j=0;    char *p;    k=strlen(source);    p = source;    for(i=start-1;i

注意事项
1

网络虽好,但要注意劳逸结合哦!

2

如果是青少年,小编在这里提示大家千万不能沉迷网络!

推荐信息