parse required info from string by strsep()
来源:互联网 发布:成功网络促销案例 编辑:程序博客网 时间:2024/06/05 07:05
/* strsep.c by vinco at 2011-08-19* Ubuntu CC/gcc-4.4.1*/#include<string.h>#include<stdio.h>#define PARAM_LENGTH 100char* strtrim(char* s);int main(){char varValue[100] = " 202.103.44.150 , 202.103.24.68 ";char* pVar2 = varValue ,*pVar1 = NULL;char dnsPrimary[PARAM_LENGTH+1],dnsSecondary[PARAM_LENGTH+1];pVar1 = strsep(&pVar2,",") ;if( pVar1 ){strncpy(dnsPrimary, strtrim(pVar1), PARAM_LENGTH);dnsPrimary[PARAM_LENGTH] = '\0';}if( pVar2 ) {strncpy(dnsSecondary, strtrim(pVar2), PARAM_LENGTH);dnsSecondary[PARAM_LENGTH] = '\0';}printf("dnsPrimary = %s \n", dnsPrimary );printf("dnsSecondary = %s \n", dnsSecondary );}/** to ignore the space char ,such as ' ','\n','\t'*/char* strtrim(char* s){int len=0,i=0,j=0,k=0;len = strlen(s);if( len == 0 ) return NULL;j = len -1;while(s[j] == ' ' || s[i] == '\t' ){s[j--] = '\0';if(j < 0 ) break;}while( s[i] == ' ' || s[i] == '\t' ) i++;if( i == 0 ) return s; while( s[k] != '\0') s[k++] = s[i++];return s;}
- parse required info from string by strsep()
- [问题]CocoaPods:XX(from `./`)` required by `Podfile`
- Parse Date-time From String With PHP & MySQL
- parse json into string from http response in java
- fbauth2 is missing from your Info.plist under LSApplicationQueriesSchemes and is required for iOS 9.
- strsep
- strsep
- strsep
- strsep
- pylint--info from google
- cocoapods ` required by `Podfile`
- experiment: parse crash info on vs2008
- java.lang.String cannot be resolved, Indirectly referenced from required .class file
- The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
- The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
- Linux 内核可用的字符串分割函数 strsep (String Split Function strsep in Linux Kernel)
- Int32.Parse(string)
- parse post xml string
- Struts2概述,Struts1的Struts2的区别
- DirectShow学习指南之数据流结束通知
- C#中类的创建
- android 的adapter介绍
- SQL 2008 express 无法安装管理工具 Management Studio Express
- parse required info from string by strsep()
- Android GoogleMaps API
- ‘weird’ kernel macros — container_of
- PHP 文件上传
- 基于 Android NDK 的学习之旅-----环境搭建
- oracle中数据类型转换
- 基于 Android NDK 的学习之旅-----Android.mk 介绍
- Java List与ArrayList的区别
- 网络管理员实用命令