Re: Dynamic Array




Hi Flash,

> Please don't use abbreviations like "u". All they do is make your post
> harder to read. Remember that many more people read your post than write
> it, so it is worth a few extra keystrokes.


> > #include<stdio.h>
>
> The space shortage was resolved years ago, so why not use spaces to make
> your code easier to read?
> #include <stdio.h>
> It is better to specify that you are not using parameters.
> int main(void)

Thanks for these tips



p= (int*)malloc(n*sizeof(int));
you should note that malloc returns void* and it is better to typecast
the return value.


A simpler expression is
> p[i] = num;
Good.

> This can again be simplified to
printf(" %d", *p[i]);

This won't work as p is pointer. It should be *(p+i) or only p[i].

All said and done. I just want to give quick idea about dynamic array.
I appreciate your keen interest in analysing code line by line.
Thanks for giving your valuable suggestions

Also I apologizes to this group for sending same reply three times. It
just happened that I was refreshing my web page and that mail was sent
thrice. I am sorry for that.
Suriya

.