dimanche 29 mars 2015

gdb Err presenting content of array with variable size



consider the following simple code. I'm trying to assign an array with variable size "size" entered by the usr. the code "behaves" with expected results.


however, if I try to view the value of array in gdb (using eclips) I get [0]. trying to display it as an array (using the expression (*array@size) or even manually right clicking on array in variable window and ask to "display as array" i get an error: "Can't take address of \"array\" which isn't an lvalue."


If i now change the assignment to be with fix size (e.g. int array[6];) everything works OK including proper display in gdb


any ideas?



int main(void) {
int size;
puts("Enter size of array:\n");
scanf("%d",&size);
int array[size];
for (int i=0;i<size;i++) {
array[i]=i;
}



Aucun commentaire:

Enregistrer un commentaire