@Nikhil : This question was asked to 2 people during Adobe interview on
Tuesdaythe above solutions are perfectly alright.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
No it will not cause a memory leak as its a string literal and it behaves
more like a read only entity.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
I believe the method written is incorrect, it didnt work for me
i guess this is the right way...worked for me:
int **p;
p=malloc(3*sizeof(int *));
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
Look we wish to allocate memory for an array of 3 integer pointers.
so when we do dynamic allocation we always store the result in a pointer to
the required data type.
for example if you wish to dynamically allocate int arr[3[]
u will write :
int *p=malloc(3*sizeof(int));
So now when you do it
The *sizeof* operator cannot be used with the following operands:
- Functions. (However, *sizeof* can be applied to pointers to functions.)
- Bit fields.
- Undefined classes.
- The type *void*.
- Dynamically allocated arrays.
- External arrays.
- Incomplete types.
-
It will be (1+2+3+,,,+n)^2.u can verify it for a chess board hich will
have 1296 rectangles for n=8
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit