0

I only know and only use printf(), but I want to try a function that can output something without the use of % parameters.

I want to do something like this:

printf("Hello, %s.\n", name);

But no longer using % for it. Something like:

foo("Hello, ");
foo(name);
foo(".\n");

Is there a function that acts like this?

1 Answers1

2

Use fputs()

fputs("Hello, ", stdout);
fputs(name, stdout);
puts(".");

Note that this can only print strings, not other types of data like you can with printf(). There's putc() and fputc() for single characters.

There's also puts() that writes only to stdout, but it also adds a newline at the end, so you can't use it as a replacement for your printf(), except for the last part that ends with newline.

Barmar
  • 741,623
  • 53
  • 500
  • 612