From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ron Michael Khu Subject: Re: Dinamic array allocation Date: Tue, 26 Oct 2004 13:15:28 +0800 Sender: linux-c-programming-owner@vger.kernel.org Message-ID: <417DDD70.3060605@hq.ntsp.nec.co.jp> References: <417DBE66.7050501@crearium.com> <417DCDE9.8000004@hq.ntsp.nec.co.jp> <417DD9BA.8040009@hq.ntsp.nec.co.jp> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <417DD9BA.8040009@hq.ntsp.nec.co.jp> List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Cc: Lejanson Go , Fabio , linux-c-programming@vger.kernel.org This is Mr. Fabio's code: main(int argc, char *argv[]) { char *Array[]; int length,i; char foo[10]="bar"; length = strlen(foo) + atoi(argv[1]); Array = malloc(length) for(i=;i I hope i am correct. :D > > ptr = (char *) malloc (strtol(argv[1])+strlen(foo)); > > > Ron Michael Khu wrote: > >> arvp[1] is string.... >> u should convert it to a numeric type via atoi() or strtol().... >> >> =) >> >> Fabio wrote: >> >>> Hi. >>> >>> I am programming a C code that gets argv[1] as the lenght of an >>> array that is the copy of an array plus more data. >>> >>> So, the appication runs as: ./a.out 100 >>> >>> It create an array of 100 bytes and adds a static defined array plus >>> more data, like: >>> >>> char *foo[5]="bar" >>> main(int argc, char *argv[]) >>> { >>> char *Ptr[]; >>> Ptr = malloc( argv[1]+strlen(foo)); >>> .... >>> } >>> >>> Makes sense? guess no. >>> >>> Any suggestion is welcome. >>> >>> thanks in advance >>> - >>> To unsubscribe from this list: send the line "unsubscribe >>> linux-c-programming" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >>> >>> >> >> - >> To unsubscribe from this list: send the line "unsubscribe >> linux-c-programming" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >> > > >