Re: Returning an array of strings in C
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Sat, 12 Nov 2005 11:12:34 GMT
wcang79@xxxxxxxxx wrote:
>
> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>
> strings = (char **) malloc(sizeof(char *) * 100);
strings = malloc(100 * sizeof *strings);
The above way is generally considered a
better style way of writing that.
> strings[i] = malloc(4);
strings[i] = malloc(3 + 1);
This makes it more obvious that string[i]
is intended to be holding a string,
instead of pointing to a string.
--
pete
.
- Follow-Ups:
- Re: Returning an array of strings in C
- From: pete
- Re: Returning an array of strings in C
- References:
- Returning an array of strings in C
- From: karthika . 28
- Returning an array of strings in C
- Prev by Date: C program to count occurences of substrings in strings
- Next by Date: Re: register
- Previous by thread: Re: Returning an array of strings in C
- Next by thread: Re: Returning an array of strings in C
- Index(es):
Relevant Pages
|