Help w/ getting the address not using '&'

I have this code that should store values and display the address and the value in that address. But the address seem to be wrong cuz the interval should be 2 only(i.e, instead of 100 -> 1, 102 ->2... it displays 100 -> 1, 108 -> 2).

[code]
#include
#include

main()
{
int *arr[30], ctr, temp, add;
clrscr();

for(ctr=0;ctr<10;ctr++)
{
arr[ctr] = (int *) malloc( sizeof(int) );
}

printf("Enter 30 nos.:");
for( ctr = 0 ; ctr < 10 ; ctr++ )
{
printf("
");
scanf("%d", arr[ctr]);
}

for( ctr = 1 ; ctr < 10 ; ctr++ )
{
printf("%d -> %d
", arr[ctr], *arr[ctr]);
}

getch();
}
[/code]

Comments

  • : I have this code that should store values and display the address
    : and the value in that address. But the address seem to be wrong cuz
    : the interval should be 2 only(i.e, instead of 100 -> 1, 102 ->2...
    : it displays 100 -> 1, 108 -> 2).
    :

    Hmmm :) Print the following:
    [code]
    sizeof(int*)
    [/code]

    I take it you are using a 64 bits system then?

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion