how to take ‘n’ strings as input and how to print them?
I did but output is showing lesser number of strings.
Also how to sort the strings using sort function.
link-https://ide.codingblocks.com/s/78915
Input multiple strings
hey Risabh you are not getting wrong answer because getline read a character till it gets newline by default(if no delimiter is specified). Here After 3 compliler is reading a blank line ending with newline delimiter, So it considering s[0] as blank line, s[1] as rishabh and s[3] as pranjul.
You can use cin instead of getline, than you will get correct output.
The works of sort function is to just sort the this array depending upon your choice(ascending or decending). This sort function just take all pairs of string out of string array and sort them.