[Solved] Why am i getting an extra line at the beginning of output?


You create a vector of size n. Then you check for each input line if the second string contains the text gmail and you store the pair in the i-th element. You increment i even if you skip the input. That means that some elements of the vector can remain empty. At the end you print all elements.

E.g. input is:

7
julia gmil
julia gmail
julia gmail
riya gmail
samantha gmail
samantha gmil
tanya gmail

You store:

m[0]:
m[1]: julia
m[2]: julia
m[3]: riya
m[4]: samantha
m[5]:
m[6]: tanya

The output after sort is

(empty)
(empty)
julia
julia
riya
samantha
tanya

solved Why am i getting an extra line at the beginning of output?