Be very carefull with pointers.
testing[pointercounter] = tempname;
When you copy the tempname to testing you only copy the pointer. The next time you change tempname you also change testing because they both point to the same space. Try using strcpy to copy the complete string.
The simplest way to solve this problem is to do the following:
Code:
int pointercounter = 0;
char tempname[30] = "";
int tempcounter = 0;
// char *testing[30];
char testing[100][30];
while (in_stream >> value &&value != '(')
{
tempname [tempcounter] = value;
tempcounter++;
} //to get the next name on the line
// testing[pointercounter] = tempname;
strcpy(testing[pointercounter], tempname);
pointercounter++;
You can read max 100 names using this array.
A better (and more difficult way) to solve this is by using dynamic arrays.
Code:
int pointercounter = 0;
char tempname[30] = "";
int tempcounter = 0;
// char *testing[30];
char **testing = NULL;
while (in_stream >> value &&value != '(')
{
tempname [tempcounter] = value;
tempcounter++;
} //to get the next name on the line
// testing[pointercounter] = tempname;
testing = realloc(testing, sizeof(char *) * (pointercounter + 1)); // allocate space for new index
testing[pointercounter] = strdup(tempname); // allocate space and copy string
pointercounter++;
Don't forget to remove allocated memory afterwards when using dynamic arrays.