I absolutely don’t have clue what the colon you’re talking about! I asked you question and you give some random :-/
ssharish
Life is like riding a bicycle. To keep your balance you must keep moving - Einstein
The quote tags put the text in italics. With a smaller font size, the regular colon ( : ) looks like a semi-colon ( ; ), hence Tater's confusion.
Last edited by anduril462; 06-20-2011 at 05:26 PM. Reason: Removed cursed smilies!
My guess is that he's assuming name will have whitespace.
Quzah.
Hope is the first step on the road to disappointment.
Mate it wont work! Have you compiling your suggesting before posting?
ssharish
Life is like riding a bicycle. To keep your balance you must keep moving - Einstein
It's not going to work because %s will happily read the : as part of the string, leading to Very Bad Things, is where we're going here I think.
Even ssharish2005's code will lead to buffer overruns if the input is not formatted correctly and all the string part buffers are not 104 characters or longer. You really do need width fields for anything with %s or %[].
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
No, even then you need %N[], with N limmited by the size of the target buffer, or else you can buffer overflow. If you're using fgets followed by sscanf, you can make all your buffers the max line length, but otherwise you need the width specifier. The advantage to the no width specifier method is you don't have a magic number as a string literal.
Last edited by King Mir; 06-21-2011 at 11:53 AM.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.