Hi
I am using GCC to compile my programs under Linux
here is my code, where is the mistake?

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

/********************************************
void new_var(char *src,char *array[])
assigns the address of a CGI POST variable to
a pointer which is a member of array[]
********************************************/
void new_var(char *src,char *array[])
{
int i=0;
char *tmp;

tmp=src;

array[i]=tmp;
i++;
while(*src)
{
if(*tmp=='&')
{
/* *tmp='\0'; */
array[i]=tmp+1;
i++;
}
tmp++;
src++;
}
} /* END OF NEW_VAR */



int main()
{
char *query="ad=fehmi+noyan&soyad=isi&no=2118444"; /*HTTP POST string*/
char *arr[3];

new_var(query,arr);

printf("\n%s \n%s \n%s\n",arr[0],arr[1],arr[2]);

return 0;
}

This program prints
ad=fehmi+noyan&soyad=isi&no=2118444
soyad=isi&no=2118444
no=2118444

But I want an output like below
ad=fehmi+noyan
soyad=isi
no=2118444

So, I uncommented the "*tmp='\0';". Trying to put a NULL to the place of "&" so I will have three different string ending with NULL. But when I run the program it gives segmentation fault! I tried strcpy(), and strncpy() to copy the NULL to the place of "&" but the result was the same . There is no error in compiling process.

NOTE: I am trying to get the variables passed with POST method in a CGI program.