double pointer allocation


 
Thread Tools Search this Thread
Top Forums Programming double pointer allocation
# 1  
Old 06-07-2012
double pointer allocation

hi guys

how can I allocate a double char pointer?
I want an array of pointers to char[] objects.

the objects the double pointer points to are :

Code:
char b[1024];

# 2  
Old 06-07-2012
Code:
char a[1024];
char b[1024];
// use either of these
// let the compiler decide how big the array is:
char *ptr[]={a, b};
// you tell it how big
char *ptr[2]={a, b};

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested variable allocation

I've made a number of errors with this and am trying to work a solution within the same framework. /bin/ksh for host_name in ahost1 ahost2 bhost1 bhost2 do for host_prefix in a b do if echo ${host_name} | grep -qi ${host_prefix} then if ... (1 Reply)
Discussion started by: squrcles
1 Replies

2. Programming

memory allocation for string in C

hi in the following code, how the memory is allocated for a1 which holds the values of a2 after cpy function call. #include <stdio.h> #include <string.h> void cpy(char* d, const char* s){ while(*d++=*s++); } main(){ char* a1; char* a2="done"; cpy(a1,a2); ... (3 Replies)
Discussion started by: mprakasheee
3 Replies

3. Solaris

Block-based allocation and Extent-based allocation in Solaris

Hi guys! Could you tell me what's this figure about? (See the attached figure below.) This is a representation of block allocation filesystem and extent allocation filesystem in Solaris. Does this mean that in a block-based allocation, data are placed in individual blocks while in... (0 Replies)
Discussion started by: arah
0 Replies

4. Programming

Memory allocation in C

Hi Experts I need some help in static memory allocation in C. I have a program in which I declared 2 variables, one char array and one integer. I was little surprised to see the addresses of the variables. First: int x; char a; printf("%u %u\n', &x, a); I got the addresses displayed... (2 Replies)
Discussion started by: unx_freak
2 Replies

5. Programming

dynamic allocation vs static allocation in c

i wrote a tiny version of tail command using a large buffer statically allocated but, in a second time, i found another version in which i use a bidimensional array dynamically allocated. here is the first version /*my tiny tail, it prints the last 5 line of a file */ #include<stdio.h>... (4 Replies)
Discussion started by: lucasclaus
4 Replies

6. Programming

pass a pointer-to-pointer, or return a pointer?

If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it: (1) one is to pass a pointer-to-pointer parameter, like: int my_malloc(int size, char **pmem) { *pmem=(char *)malloc(size); if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies

7. Programming

Pointer to a struct (with pointers) *** glibc detected *** double free

I am using a structure defined as follows struct gene_square { double *x; double *y; };I have class, with a member function which is a pointer of this type: gene_square* m_Genes;I am allocating memory in the constructors like this: m_Genes = new gene_square; for (ii=0;... (1 Reply)
Discussion started by: jatoo
1 Replies

8. UNIX for Dummies Questions & Answers

HOw to get a variable allocation

HI Gurus, I had a requirement where i want to allocate a file name into a variable and get the file name in the subj of email. Suppose i have a file File002.pdx in the folder /home/pcs/system/files/File002.pdx Iam using a variable a = `ls /home/pcs/system/files/*.pdx` Iam using *... (2 Replies)
Discussion started by: pssandeep
2 Replies

9. Programming

double pointer usage

Hi, Is there anything wrong in the following code : - Because I am freeing the local variable tt, will it affect 'str' variable in the main function. will there be any memory leaks for bulk requests? Thanks in advance main(){ char *str="hi"; fun(&str); ... (6 Replies)
Discussion started by: axes
6 Replies

10. UNIX for Dummies Questions & Answers

memory allocation

I would like to know how I could allocate some more memory to a process. Please note that I am not the root user. (1 Reply)
Discussion started by: sagar
1 Replies
Login or Register to Ask a Question