[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: HI please tell what could be the problem
Hi
BTW, are you sure of your malloc? I think you should put 5*sizeof(char*)
because you will be allocating 5 strings there.
So prototype the function, remove int from for statement(not allowed in C),
and put 5*sizeof(char*) and it will work. I tried and it worked....
As Binand said in other mail, anything that talks 'void main(){}' is not C,
it's dos...
Shridhar
P.S. Seriously consider to get two mail ids from company. One for office and
other for personal mails. This signature business on list mail, is a ever
growing pain....
On Friday 23 March 2001 19:13, Kondaiah (IE10) wrote:
> void main()
> {
> char **p=NULL;
>
>
> p=(char**)malloc(sizeof(char*));
> doublealloc(p);
> for(int i=0; i<5; i++)
> {
> printf("%s\n",p[i]);
> }
> }
>
> void doublealloc(char **p)
> {
> int i=0;
> for(i=0;i<5; i++)
> {
> p[i]=(char*)malloc(64);
> strcpy(p[i],"Kondaiah");
> }
> }