Re: Dynamic Array
- From: "suriya" <aktersuriya@xxxxxxxxx>
- Date: 10 Oct 2005 02:38:07 -0700
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
.
- Follow-Ups:
- Re: Dynamic Array
- From: Martin Ambuhl
- Re: Dynamic Array
- From: Flash Gordon
- Re: Dynamic Array
- References:
- Dynamic Array
- From: chai
- Dynamic Array
- Prev by Date: Re: lvalue cast
- Next by Date: Re: C at its finest
- Previous by thread: Re: Dynamic Array
- Next by thread: Re: Dynamic Array
- Index(es):