Reputation: 277
getline reads the input and further modifies it with the help of sscanf, how can I keep spaces in a variable st.m_Jmeno in the form of "something something"
while ( getline(&str, &capacity, stdin) != -1 )
{
sscanf(str,"%c %s %c %s", znak, st.m_Cislo,uvozovka, st.m_Jmeno);
...
Upvotes: 0
Views: 152
Reputation: 126253
You can use a %[
pattern to get everything else in the line:
sscanf(str,"%c %s %c %[^\n]", &znak, st.m_Cislo,uvozovka, &tmp, st.m_Jmeno);
Note that this is (still) dangerous, in that it might overrun either string buffer if the input is too long.
Upvotes: 1