I believe this
Quote:
[^$]
is telling scanf to stop when you type the $ character.. if you did this
[^\n]
it would stop when you use the return key (ie, \n is NOT in the valid character class, so input stops)
All this being said, scanf is usually used to get formatted input, using it to read unformatted input into a buffer as you are doing, and not a large buffer at that, can cause also sorts of nasty things to happen
edit - you could try and make it a bit safe by using
scanf("%19[^\n]")
given your buffer size of 20