+ 8

How can i keep taking input string from the user until there is no more data entered ?

I want to take an array of string from the user and end waiting when there is no more data entered. Without asking for the number of elements ? Any help please ?

20th Aug 2020, 4:36 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
7 Antworten
+ 1
No Ahmed Mahmoud i make it as example but what language you use c or c++??
20th Aug 2020, 5:01 PM
HBhZ_C
HBhZ_C - avatar
+ 5
HBhZ_C check this question please it wrote the function for that but still stacking at how to take the query of the user ? https://www.hackerrank.com/challenges/30-dictionaries-and-maps/problem
20th Aug 2020, 5:14 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
+ 4
but there is no pre-defined length of the array of string and what user_input ? is it a built in type defined data ?
20th Aug 2020, 4:59 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
+ 4
HBhZ_C i use C
20th Aug 2020, 5:07 PM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
+ 2
Set a condition in while loop as like while(user_ input < string_length) .....
20th Aug 2020, 4:54 PM
HBhZ_C
HBhZ_C - avatar
+ 2
Ahmed Mahmoud You have to read input from the user until he finished typing and return this input length in this example from stackoverflow.com how can i read an input string of unknown length he use realloc function.Check it and sorry i can not access hackerrank without account .
20th Aug 2020, 5:22 PM
HBhZ_C
HBhZ_C - avatar
+ 2
Ahmed Mahmoud In c++ you have to declare map for phonebook and set for loop for name and number phone string user input .then check if key enteted by the user match phonebook name or not
20th Aug 2020, 5:51 PM
HBhZ_C
HBhZ_C - avatar