pointer and malloc [closed]
- by gcc
How many methods/ways are there taking input by using with pointer and dynamic memory?
Input:
3 1 2 n k l 2 1 2 p 4 55 62 * # x
(x is stop value, first input always integer)
Example code:
p=malloc(sizeof(int));
scanf("%d",&num_arrays);
while(1)
{
scanf("%c",&(*(p+i)));
if(*(p+i)=='x')
break;
++i;
}
"3" is stored in num_arrays. The other input values are stored in pointer[array].