c语言实现名值对通过key查找value

需求、例如:

1、" key1 = value1 " 通过"key1"从该字符串中查找出"value",value去除前后空格

2、" key1 == value1 " 、" key1 = = value1 " 双等于号不合法

头文件:

#include<stdlib.h>
#include<stdio.h>
#include<string.h>

函数原型:

void trim(char *strIn /*in*/, char *strOut /*out*/);

void getValue(char * keyAndValue  /*in*/, char * key  /*in*/, char * value /*out*/);

实现方法:

 1 void trim(char *strIn, char *strOut){
 2 
 3     char *start, *end, *temp;//定义去除空格后字符串的头尾指针和遍历指针
 4 
 5     temp = strIn;
 6 
 7     while (*temp == ' '){
 8         ++temp;
 9     }
10 
11     start = temp; //求得头指针
12 
13     temp = strIn + strlen(strIn) - 1; //得到原字符串最后一个字符的指针(不是' ')
14 
15     while (*temp == ' '){
16         --temp;
17     }
18 
19     end = temp; //求得尾指针
20 
21 
22     for(strIn = start; strIn <= end; ){
23         *strOut++ = *strIn++;
24     }
25 
26     *strOut = '