讨论/题目交流/为啥 p1 输出来不对呢?/
为啥 p1 输出来不对呢?
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int getKeyByValude2(char *keyvaluebuf, char *keybuf, char *valuebuf,int *valuebuflen)
{
	char *keyvaluebuf1 = keyvaluebuf;
	char *valuebuf1 = valuebuf;
	char *keybuf1 = keybuf;
	int *valuebuflen1 = valuebuflen;
	int i = 0;
	int j = 0;
	
	int b = 0;
	//去空格
	while (keyvaluebuf[j] != '\0')
	{
		if (keyvaluebuf[j] != ' ')
		{
			*keyvaluebuf1 = keyvaluebuf[j];
			keyvaluebuf1++;
		}
		j++;
	}
	*keyvaluebuf1 = '\0';
	//实现函数
	int a = strlen(keyvaluebuf);
	while (keyvaluebuf[i] != '=')
	{
		*keybuf = keyvaluebuf[i];
		i++;
		keybuf++;
	}
	*keybuf1 = '\0';
	for (; i < a; i++)
	{
		*valuebuf = keyvaluebuf1[i];
		valuebuf++;
	}
	*valuebuf= '\0';
	b = strlen(valuebuf1);
	*valuebuflen1 = b;
	
	
	
}
int main()
{ 
	char p[] = "    key1  =    value1     ";
	char p1[50] ;
	char p2[50] ;
	int p3;
	//getKeyByValude(p, p1,p2);
	getKeyByValude2(p, p1, p2,&p3);
	printf("p=\"%s\"\np1=%s\np2=%s\np3=%d",p, p1,p2,p3);
	system("pause");
}
展开讨论
GODBLESSYOU发起于 2019-08-30
最近编辑于 2019-08-30
共 0 个讨论
无讨论