V
VijaKhara
Hi all,
I just write a very simple codes in C and vthere is a very strange bug
which I cannot figure out why.
The first loop is for v[j], and the second for k. There is no
relationship between v and k but if I debug and watch the change of
the variable after each command.
When the sencond loop happends for k, the values of v[j]s change
and are set to be equal some values of k. Specifically, v[1][1] is
set to be 10, so is v[1][2] .
I don't understand why. It seems that both v and k point to the same
address in memory.
This is very strange.
(I write this C code in Visual Studio 6 and debug it in Visual Studio
6)
Thanks
#include <math.h>
#include <stdlib.h>
#include "time.h"
void error(char *name);
int main (int argc, char **argv)
{
double v[3][3];
double k[3];
int i,j,l;
for (i=0;i<3;i++)
for(j=0;j<3;j++)
v[j]=4;
for (i=0;i<9;i++)
{
k=10;
}
return(0);
}
void error(char *name)
{
printf("usage: %s image.tiff \n\n",name);
exit(1);
}
I just write a very simple codes in C and vthere is a very strange bug
which I cannot figure out why.
The first loop is for v[j], and the second for k. There is no
relationship between v and k but if I debug and watch the change of
the variable after each command.
When the sencond loop happends for k, the values of v[j]s change
and are set to be equal some values of k. Specifically, v[1][1] is
set to be 10, so is v[1][2] .
I don't understand why. It seems that both v and k point to the same
address in memory.
This is very strange.
(I write this C code in Visual Studio 6 and debug it in Visual Studio
6)
Thanks
#include <math.h>
#include <stdlib.h>
#include "time.h"
void error(char *name);
int main (int argc, char **argv)
{
double v[3][3];
double k[3];
int i,j,l;
for (i=0;i<3;i++)
for(j=0;j<3;j++)
v[j]=4;
for (i=0;i<9;i++)
{
k=10;
}
return(0);
}
void error(char *name)
{
printf("usage: %s image.tiff \n\n",name);
exit(1);
}