zoukankan      html  css  js  c++  java
  • c语言任意格式输入提取算法

    今天看到一个比较好的代码,拿过来分享一下,代码的主题是用户可以输入256个任意字符,然后以格式提取的方式来得到数据,是不是挺好的。

    代码如下:

    #include <stdio.h>

    void main(){
    static unsigned char sInput[256];
    int iRet;
    int offset;

    printf("please input offset:");
    fgets(sInput, sizeof(sInput), stdin);
    iRet = sscanf(sInput, "%d", &offset);
    if (iRet < 1){
    printf("Invalid option\n");
    }
    printf("the offset is %d\n",offset);
    }
    运行结果如下:
    please input offset:926a
    the offset is 926
    Press any key to continue
     
  • 相关阅读:
    【原】戏说Java
    git分支branch合并到主分支master
    环境搭建
    zookeeper简单实战
    zookeeper介绍
    临时表与中间表
    避免活跃性
    sss
    sss
    sss
  • 原文地址:https://www.cnblogs.com/fishoneseaatblog/p/2266637.html
Copyright © 2011-2022 走看看