Linked Questions

9 votes
5 answers
3k views

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 ...
BiGYaN's user avatar
  • 7,215
5 votes
4 answers
2k views

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 ...
Mordy Shahar's user avatar
3 votes
1 answer
2k views

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 ...
nalzok's user avatar
  • 16.4k
8 votes
3 answers
174 views

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. #...
biswas N's user avatar
  • 381
1 vote
2 answers
5k views

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 ...
Fekete Ferenc's user avatar
0 votes
7 answers
735 views

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 ...
Sayalic's user avatar
  • 7,558
1 vote
3 answers
4k views

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 (...
Jonathan's user avatar
  • 752
2 votes
4 answers
1k views

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%...
Aboelnour's user avatar
  • 1,435
-3 votes
3 answers
2k views

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)); }
Victor Hanukayev's user avatar
1 vote
4 answers
2k views

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 ...
Dilini Peiris's user avatar
0 votes
4 answers
926 views

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> ...
Coderandhacker's user avatar
2 votes
5 answers
506 views

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,...
rafi wiener's user avatar
-1 votes
3 answers
725 views

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,...
Hari's user avatar
  • 121
2 votes
3 answers
199 views

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....
Fionser's user avatar
  • 171
-1 votes
2 answers
797 views

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",...
md.jamal's user avatar
  • 4,717

15 30 50 per page
1
2 3 4 5
10