
HELP Please Please (malloc on an array)
All I need to do is create an array of strings in memory. Not a hard task at
all. I can do this easily using the following code but I have had problems
trying to do this dynamically with malloc etc. I haven't used malloc much
and don't have the time to get it by trial and error.
Could someone please help me as I need to get this done very quickly.
Code using standard char array
------------------------------
main()
{
char array1[1000][11];
int temp;
for(temp=0;temp<999;temp++)
sprintf(array1[temp],"Test %d",temp);
printf("\n\nEnter a number :");
scanf("%d",&temp);
printf("\n%s",array1[temp]);
Quote:
}
Code using malloc etc
---------------------
(fill in here, Please)
Thanx in advance.
Matt Thompson
Software Technician
Christchurch Polytechnic
New Zealand