侧边栏壁纸
    • 累计撰写 296 篇文章
    • 累计收到 520 条评论
    通信滤除$字符分段保留重要信息代码
    我的学记|刘航宇的博客

    通信滤除$字符分段保留重要信息代码

    刘航宇
    2021-03-21 / 1 评论 / 186 阅读 / 正在检测是否收录...

    通信中滤除$字符分段保留重要信息代码
    实现效果

    初级代码main实现

    #include "stdio.h"
    int main() {
    int i, j;
    char temp[16][32] = { 0 };
    char str[128] = { 0 };
    printf("please input a string\n");
    scanf("%s", str);
    printf("%s\n", str);
    char* p = &str[0];
    i = 0; j = 0;
    while (1)
    {
    if (*p == 0)
    {
    break;
    }
    if (*p != '$')
    {
    temp[i][j] = *p;
    j++;
    }
    else
    {
    i++;
    j = 0;
    }
    p++;
    }
    for (j = 0; j <= i; j++)
    {
    printf("%s\t", temp[j]);
    }
    return 0;
    }
     

    进阶调用函数

    #include "stdio.h"
    void fun(char *p){
    int i,j;
    char temp[16][32]={0};
    i=0;
    j=0;
    while(1)
    {
        if(*p==0)
        {break;}
        if(*p!='$')
        {
        temp[i][j]=*p;
        j++;
        }
        else
        {i++;
        j=0;
        }
        p++;
    
    }
    for(j=0;j<=i;j++)
    {
    printf("%s\t",temp[j]);
    }
    return;
    }
    int main(){
    char str[128]={0};
    printf("please input string\n");
    scanf("%s",str);
    fun(str);
    printf("\n");
    return 0;
    }

    再次进阶

    #include "stdio.h"
    int len;
    char **fun(char *p){
    int i,j;
    static char *m[16];
    static char temp[16][32]={0};
    i=0;
    j=0;
    while(1)
    {
        if(*p==0)
        {break;}
        if(*p!='$')
        {
        temp[i][j]=*p;
        j++;
        }
        else
        {i++;
        j=0;
        }
        p++;
    
    }
    for(j=0;j<=i;j++)
    {
    printf("%s\t",temp[j]);
    }
    len=i+1;
    for(i=0;i<16;i++)
    {
    m[i]=&temp[i][0];
    }
    return m; //&m[0]
    }
    int main(){
    char **k;
    int i;
    char str[128]={0};
    printf("please input string\n");
    scanf("%s",str);
    k=fun(str);
    for(i=0;i<len;i++){
        printf("%s\t",*k);
        }
    return 0;
    }
    
    3
    直角、球、柱坐标系转化
    « 上一篇 2021-03-22
    二元函数的极值及其求法
    下一篇 » 2021-03-20

    评论 (1)

    取消
    1. 头像
      默默
      Windows 10 · Google Chrome

      nb

      回复