printf until certain character

Jul 16, 2011 at 5:48am
closed account (o1vk4iN6)
Is there a printf format to continue printing a string buffer until a certain character has been reached, almost like setting a character as a null terminator. I know there is something similar to this with scanf:

scanf("%[^\t]s", buf);

Basically it'll continue reading characters into "buf" until tab than enter is pressed.
Jul 16, 2011 at 6:11am
Not that I know of. printf() prints C-strings, which are terminated with a null character. You could, I suppose, search the string beforehand and replace the character you want to stop at and replace it with a null character, or determine the size and print only a substring.
Topic archived. No new replies allowed.