Here is my current situation. I have a global array and it is originally declared as an int pointer. I malloc (100*sizeof(int)) to this pointer in the main method. I then use this array to store values and these values are assigned inside of two for loops. The problem is that as soon as I exit the loops and check the values they are all gone and equal zero. I confirm this with a printArray method that calls the prints the values of the array upon exiting the loops. I have included this below.
void compare(char *sub)
{
extern char *target;
int len;
int scoreofseq;
len = strlen(sub);
extern size_t ll,sl;
char *subspacer;
subspacer=(char*)malloc(100*sizeof(char));
strncpy(subspacer,sub+(ll+1),ll+sl);
char first;
first=subspacer[0];
char last;
last=subspacer[strlen(subspacer)-1];
if((first==s1)&&(last==sN))
{
double gcount;
gcount=gc(subspacer);
if(gcount<.5)
{
int pos;
int j;
int i;
char s;
char *a;
a=(char*)malloc(100*sizeof(char));
for ( pos=1, i=0; pos <= len; ++pos,i++)//This is the first loop
{
s=sub[pos];
strcpy(a,getMatches(target));
printf("A is %s\n",a);
for( j=0;j<strlen(a);j++)//This is the second loop
{
if (a[j]==s)
{
match[j]=1;
}
else
{
match[j]= 0;
}
/*When the print array was called here it printed out 1's where they were assigned*/
}
//Print array also printed out 1's here as well.
}
printArray();// I call this and it prints out nothing but zeroes
}
scoreofseq=score();
information.sc=scoreofseq;
information.gcfr=gcount;
}
free(subspacer);
}
The Print Array method
void printArray()
{
int i;
for(i=0; i<100;i++)
{
if(match[i] == 1)
printf("Match %d = %d\n",i,match[i]);
}
}
The array is globally assigned before the main method and the memory is allocated like so in the main method--> match=(int*)malloc(100*sizeof(int));
If you need me to include the main method I can but it was quite long and really the only thing that pertains to this is the malloc() call inside of it.Thanks for your time in advance!--Robert