1st I think of creating an array of pointers of size 100 as this is the
maximum input I intend to take. I can create a fixed size array but in the
end I want my array to expand at run-time to fit the size of input. I am
not able to come up with anyting all all and doing:
char* arr_of_pointers[100];
seems like a completely wrong idea as this is a static array. I want to
take the input and then decide how much memory I need and then malloc the
array of that size. I came up with K&R2 idea:
1.) read and save the input lines till the user hits the EOF
2.) sort them
3.) print them
I am pretty much confused on what to start with. Can I have your ideas in
solving this problem ? All I can think of is:
use sort algorithm from the standard library to sort the lines.
print the lines using %s as argument in printf().
--
my email ID is at the above address
maximum input I intend to take. I can create a fixed size array but in the
end I want my array to expand at run-time to fit the size of input. I am
not able to come up with anyting all all and doing:
char* arr_of_pointers[100];
seems like a completely wrong idea as this is a static array. I want to
take the input and then decide how much memory I need and then malloc the
array of that size. I came up with K&R2 idea:
1.) read and save the input lines till the user hits the EOF
2.) sort them
3.) print them
I am pretty much confused on what to start with. Can I have your ideas in
solving this problem ? All I can think of is:
use sort algorithm from the standard library to sort the lines.
print the lines using %s as argument in printf().
--
my email ID is at the above address
Comment