Bonjour à tous

J'ai une segmentation fault lorsque j'utilise strcmp dans le contexte suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
typedef struct
{
	char pchLabel[256];
	char pchValue[256];
} structLabelValue;
 
 
char* getOidValueFromArray(structLabelValue* array, const char* pchOidLabel )
{
	int nOidNum = 0;
	char* pchValue = (char*) malloc (256);
 
	for ( nOidNum = 0; nOidNum < 256; nOidNum++ )
	{		
		if ( !strcmp(array[nOidNum].pchLabel, pchOidLabel) )
			strcpy(pchValue, array[nOidNum].pchValue);
	}
 
	return pchValue;
}
 
 
void main(int argc, char *argv[])
{
	char* pchOidValue;
 
	pchOidValue = getOidValueFromArray(arrayLabelValue, "networkSatIfOamIpAddrOID_0");
 
	free(pchOidValue);
	pchOidValue = NULL;
}
Qu'en pensez-vous ?