C 语言 分割字符串 strtok函数
2013-05-21 10:00
447 查看
#include <stdio.h>
#include <string.h>
char name[20];
int split_string(char input[], char output[])
{
char *p;
int i=0;
const char *split="=";
memset(output, 0, sizeof(output));
p = strtok(input, split);
while(p)
{
if(i ==0 )
{
strcpy(output, p);
printf("%s\n", name);
}
else
{
strcpy(output, p);
printf("%s\n", output);
}
i++;
p=strtok(NULL, split);
}
return 0;
}
int main(int argc, char ** argv)
{
char a[16];
char buff[16];
strcpy(a, argv[1]);
split_string(a, buff);
return 0;
}
//==========================================================================
#include <stdio.h>
#include <string.h>
char name[20];
int split_string(char input[], char output[6][2])
{
char *p;
int i=0;
const char *split=":";
p = strtok(input, split);
while(p)
{
strcpy(output[i], p);
printf("%s\n", output[i]);
i++;
//printf("%s\n",p);
p=strtok(NULL, split);
}
return 0;
}
int main()
{
char a[20];
char buff[6][2];
char data[]="11:22:33:44:55:66";
strcpy(a, data);
split_string(a, buff);
return 0;
}
//==========================================================================
#include <stdio.h>
#include <string.h>
int split_string()
{
int i=0;
const char *split="\n";
char buff[256]="hello\nwork";
char *p;
char first[32],second[32];
memset(&buff,0,sizeof(buff));
p = strtok(temp,split);
while(p)
{
if(i == 0)
strcpy(first,p);
else if(i == 1)
strcpy(second,p);
i++;
p=strtok(NULL,split);
}
return 0;
}
#include <string.h>
char name[20];
int split_string(char input[], char output[])
{
char *p;
int i=0;
const char *split="=";
memset(output, 0, sizeof(output));
p = strtok(input, split);
while(p)
{
if(i ==0 )
{
strcpy(output, p);
printf("%s\n", name);
}
else
{
strcpy(output, p);
printf("%s\n", output);
}
i++;
p=strtok(NULL, split);
}
return 0;
}
int main(int argc, char ** argv)
{
char a[16];
char buff[16];
strcpy(a, argv[1]);
split_string(a, buff);
return 0;
}
//==========================================================================
#include <stdio.h>
#include <string.h>
char name[20];
int split_string(char input[], char output[6][2])
{
char *p;
int i=0;
const char *split=":";
p = strtok(input, split);
while(p)
{
strcpy(output[i], p);
printf("%s\n", output[i]);
i++;
//printf("%s\n",p);
p=strtok(NULL, split);
}
return 0;
}
int main()
{
char a[20];
char buff[6][2];
char data[]="11:22:33:44:55:66";
strcpy(a, data);
split_string(a, buff);
return 0;
}
//==========================================================================
#include <stdio.h>
#include <string.h>
int split_string()
{
int i=0;
const char *split="\n";
char buff[256]="hello\nwork";
char *p;
char first[32],second[32];
memset(&buff,0,sizeof(buff));
p = strtok(temp,split);
while(p)
{
if(i == 0)
strcpy(first,p);
else if(i == 1)
strcpy(second,p);
i++;
p=strtok(NULL,split);
}
return 0;
}
相关文章推荐
- perl语言:分割路径字符串,获取文件名
- Swift3.0语言教程分割字符串与截取字符串
- C语言分割字符串strtok函数
- 【摘录】C语言中利用 strtok函数进行字符串分割
- 标准C中strtok函数分割字符串
- C语言数据结构实现字符串分割的实例
- C 语言 字符串命令 strstr()的用法 实现将原字符串以分割串分割输出【转】
- 标准C中strtok函数分割字符串
- strtok函数实现字符串分割
- c++ 字符串分割一、用strtok函数进行字符串分割 原型: char *strtok(char *str, const char *delim); 功能:分解字符串为一组字符串。 参数说明:
- strtok函数的妙用,分割字符串
- strtok函数分割字符串
- C 语言 实现 字符串 分割 函数(返回"二维字符数组",及分割后的字符数组的长度)
- strtok函数,分割字符串
- C/C++_字符串分割strtok函数
- 用strtok函数分割字符串
- C 语言 字符串命令 strstr()的用法 实现将原字符串以分割串分割输出
- [C 语言]将一字符串分割,并将结果保存到数组里面 separate_string_to_array
- C 语言 实现 字符串 分割 函数(返回"二维字符数组",及分割后的字符数组的长度)
- LoadRunner中使用strtok函数分割字符串