Linked Questions

44 votes
7 answers
58k views

Possible Duplicate: How to find the sizeof( a pointer pointing to an array ) I understand that the sizeof operator is evaluated and replaced with a constant at compile time. Given that, how can a ...
Untamed's user avatar
  • 443
25 votes
4 answers
118k views

Possible Duplicate: How to find the sizeof(a pointer pointing to an array) I'm learning how to create a dynamic array in C, but have come across an issue I can't figure out. If I use the code: ...
GCBenson's user avatar
  • 536
21 votes
5 answers
70k views

I'm having trouble finding the length of an pointer array. Let's say I have: char array[40] = "hello"; // size 40 int length = sizeof array / sizeof array[0]; // no problem returns 40 //How do I get ...
Anthony Raimondo's user avatar
3 votes
3 answers
28k views

Possible Duplicate: How to find the sizeof(a pointer pointing to an array) I declared a dynamic array like this: int *arr = new int[n]; //n is entered by user Then used this to find length of ...
Jatin's user avatar
  • 14.3k
4 votes
5 answers
17k views

Is there any way I could find how much bytes are allocated for RandomArray in this code #include<stdio.h> #include<stdlib.h> int main() { int *RandomArray; int n; ...
Rafael's user avatar
  • 79
0 votes
4 answers
813 views

i run the following code but it kept printing "4" why its printing "4" and not "12"? and can I use malloc and then sizeof?(if i can then how) #include<stdio.h> int main() { int arr1[3]={1,...
Yuval David's user avatar
3 votes
2 answers
1k views

Lets be the following code: int x; int *p = &x; int t[3]; Then sizeof returns: sizeof(x) -> 4 sizeof(p) -> 8 sizeof(t) -> 12 I suppose that sizeof(t) is the result of 3 * sizeof(int). ...
intermet's user avatar
2 votes
2 answers
14k views

Possible Duplicate: How to find the sizeof(a pointer pointing to an array) When declaring a char pointer using malloc for example. is there a way to determine the allocated length. Example, if I ...
Moataz Elmasry's user avatar
1 vote
2 answers
17k views

as part of a larger task I'm trying to print the length of an array in C, i.e how many elements are in an array. The array is an array of doubles, and I want to print a single integer which is how ...
Isaac's user avatar
  • 20
0 votes
4 answers
2k views

I have the below code: int* d = (int*) malloc(100 * sizeof(int)); cout<<"size of d which is pointer is: " << sizeof(d)<<endl; I know that sizeof outputs 4 as d is a ptr. But, ...
Programmer's user avatar
  • 6,783
0 votes
1 answer
4k views

Is there a way to determine the size of a char[] buffer via a char* pointer in C++? I'm using C++98. The following lines of code all print out '8' (essentially sizeof(char*)). However I'm looking for ...
Walklikeapenguin's user avatar
1 vote
5 answers
732 views

Possible Duplicate: How to find the sizeof(a pointer pointing to an array) In the first call to strcpy_s the compiler can deduce the array length, but in the second call the array length has to be ...
Joseph King's user avatar
  • 5,237
1 vote
3 answers
3k views

Hi I have an array defined in my header filed private: Customer** customerListArray; In my cpp file I set it as following, customerListArray = new Customer* [data.size()]; cout << "arr ...
Achintha Gunasekara's user avatar
1 vote
3 answers
3k views

I'm a little confused when I run the code below: int Maxi(int A[]) { return sizeof(A)/sizeof(A[0]); } int main() { int A[5] = {1,2,3,4,5}; print("%d \n", Maxi(A)); return 0; } And I ...
ray6080's user avatar
  • 893
2 votes
3 answers
206 views

Is there a function (that could be written) which allows to know the size of an array defined with new: int *a=new int[3]; *a=4; *(a+1)=5; *(a+2)=6; Thanks!
The Newbie Toad's user avatar

15 30 50 per page
1
2 3 4 5
23