Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
is it possible to create an array whose each element is a pointer in c language.
if it is possible then how to do that...
Posted

Yes, it is possible and you should already know that, because the entry point of every C program, that is the main function, can have the following signature
C
int main(int argc, char * argv[])
 
Share this answer
 
v2
 
Share this answer
 
Comments
nv3 17-Oct-13 8:37am    
Funny thing -- didn't know that one yet.
 
Share this answer
 
v2
yes it is possible to create an array whose each element is a pointer.

if you have used linked list and character pointers than you might be familiar with the fact
that they makes use of the pointer variables to append the elements


C++
char *ch = "ASDFGH";


here ch will hold the initial position of the string but when you print the whole string
using printf("%s",ch); you will get the complete string.

and suppose you have taken an char *Array[20] it will take 20 elements and each of the element would a pointer .

C++
int main()
{
 char *arr[20];
 char ch = 0;

   while(ch<20)
   {
    arr[ch] = &ch; 
    ch++; 
    printf("%d\n",*arr[ch]);
   }
  getch();
}


[edit]Code block added[/edit]
 
Share this answer
 
v3
best option you can search on google get immediately solutions .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900