+ 2

How van we make n array without knowing n?

For example i'll be given n line that each line includes series of x & y and i want to save each line in one array . How i can i do it?

31st Dec 2019, 11:14 AM
Maryam K
Maryam K - avatar
2 odpowiedzi
+ 3
TBH I'm not getting your illustration clearly. What are x and y? and how you want to have their series? Maybe an example to improve the illustration clarity?
31st Dec 2019, 11:50 AM
Ipang
+ 2
Hi Maryam K If you are getting the size of n from user input, you can use dynamic memory allocation to create the necessary arrays. Take a look on the memory allocation function malloc, calloc and realloc. They will aid you to create variable size arrays. Good luck.
31st Dec 2019, 12:39 PM
Mark