Linked Questions
146 questions linked to/from How come an array's address is equal to its value in C?
9 votes
5 answers
3k views
Why is address of an array variable the same as itself? [duplicate]
In C, if we have an array like a[10], then a and &a have the same pointer value (but not the same type). I want to know why was C designed like this? Was this to save the additional space ...
5 votes
4 answers
2k views
Using memcpy with array name [duplicate]
Possible Duplicate: C: How come an array's address is equal to its value? I recently found code in my project that calls memcpy with the address of array name int a[10]; memcpy(&a, &b ...
3 votes
1 answer
2k views
Why scanf("%s",&str); behaves as scanf("%s",str);? [duplicate]
Look at the following code: #include <stdio.h> int main() { char str[80]; int n; scanf("%s%n",str,&n); printf("%s\t%d",str,n); putchar('\n'); getchar(); //to remove ...
8 votes
3 answers
174 views
Pointer in 2D Array [duplicate]
As a beginner programmer I am dealing with some simple problems related to Pointers. In the following code I found the value of *a and a are same in hexadecimal. But I can't understand the reason. #...
1 vote
2 answers
5k views
What is the difference in C between &i and i if i is an array of integers? [duplicate]
I tried a code to see what is the difference between &i and i if i is an array. My assumption was that i represents the starting address of the array, and I had no idea what will happen if I print ...
0 votes
7 answers
735 views
If a is array(such as int a[4];),then what is &a? [duplicate]
Possible Duplicate: C: How come an array’s address is equal to its value? I test in GCC 4.4.1 and I find &a=a. I can't understand it. I think &a should be the address where stores the ...
1 vote
3 answers
4k views
C++: When using memcpy, what is the difference between myArray and &myArray? [duplicate]
Possible Duplicate: How come an array’s address is equal to its value in C? In the situation: int x = 5; unsigned char myArray[sizeof (int)]; This line... memcpy (&myArray , &x , sizeof (...
2 votes
4 answers
1k views
address of array ptr equal to to it's value? [duplicate]
Possible Duplicate: C: How come an array’s address is equal to its value? SA In C I tried to print the address of the pointer of an array. int a[3] = {0,1,2}; printf("\n%p",a); printf("\n%...
-3 votes
3 answers
2k views
What is the difference between arr and *arr? [duplicate]
What is the difference between these 2 prints, I got the same address in both of them : int main(void) { int arr[2][3] = {{1,2,3},{4,5,6}}; printf("%p\n", arr); printf("%p\n", *(arr)); }
1 vote
4 answers
2k views
How can array name and the address of the array name both prints the same value? [duplicate]
Consider the following code snippet. int main(){ int x[2]; x[0]=100; x[1]=200; printf("%d\n",x); printf("%d\n",&x); printf("%d\n",*x); } The output is given as (in ...
0 votes
4 answers
926 views
Why in a 2D array a and *a point to same address? [duplicate]
I am just trying to learn how 2D arrays implemented and how memory allocation takes place. so I get some doubt in the given c program that why a and *a giving same address. #include<stdio.h> ...
2 votes
5 answers
506 views
zero an array inside a struct in c++ [duplicate]
I have a struct defined in my program. struct A{ int arr[10]; } Lets say I have a pointer to it. A * a = new A; I can zero it in two ways: memset(&a->arr,0,sizeof(A)); memset(a->arr,0,...
-1 votes
3 answers
725 views
How can an address have multiple values? [duplicate]
int i[5]={0,1,2,3,4,}; int *ip=&i[0]; printf("%d,%d,%d,%d,%d,%d,%d,%d",*ip,ip,&ip,&i,&i[0],i,i[0],*(&i)); The output of above piece of code that I got in my comp is 0,2358832,...
2 votes
3 answers
199 views
Shouldn't the address of an array be a double pointer? [duplicate]
Possible Duplicate: C: How come an array’s address is equal to its value? int a[2]; printf("%u %u", (int)(&a), (int)(a)); I am thinking that &a is a pointer that points to the address of a....
-1 votes
2 answers
797 views
Assignment from incompatible pointer type warning on arrays [duplicate]
Why is the below code giving a warning? #include <stdio.h> int main() { int arr[3] = {1,2,3}; int *ptr, *ptr1; ptr = &arr; ptr1 = arr; printf("ptr is %p\t ptr1 is %p\n",...