L
L
Luke LikeSkywalker2018-10-29 10:13:03
go
Luke LikeSkywalker, 2018-10-29 10:13:03

What is the difference between Sprintf, Printf, Fprint?

When should you use Sprintf, Fprintf, Printf? Same for Scan. What are the differences between these prefixes F, S?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
MGNeo, 2018-10-29
@oolooq

sprintf: s - string, print - print, f - formatted mode; formatted print to line.
fprintf: f - file; formatted print to file.
printf: formatted print to a standard location, usually the console.

A
Andrey Burov, 2018-10-29
@BuriK666

https://golang.org/pkg/fmt/#Printf
https://golang.org/pkg/fmt/#Sprintf
https://golang.org/pkg/fmt/#Fprintf

S
stratosmi, 2018-10-29
@stratosmi

It differs in where the result is given.
To a string, to an io.Writer (for example, to a file, to a network, etc.) and to a screen (to a console).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question