Notes on standard input / output of Go

background

I am studying Golang while translating C language into Golang.

No, I've been doing it for a long time, but I haven't made much progress in my research. I don't want to neglect to study programming in order to support various languages after getting a job.

However, Golang, personally, is hard to get along with C language.

This time as well, I will note that it fits firmly in the basics of the basics.

The function that fits this time

This is it.

<stdio.h>
printf("Hello, world!\n");

Golang standard output function

There are many because it is a latecomer language.

import "fmt"
fmt.Print("Hello, world!\n")
fmt.Printf("Hello, world!\n")
fmt.Println("Hello, world!\n")

Now the problem. Which one behaves the same as the C printf () function?

answer

I'm not confident, but I felt the third was the closest in the test results.

See here for details.

Standard input

It's easy to overlook both the standard C input (scanf ()) and the standard Golang input (fmt.Scanf ()).

** Separate strings with spaces. ** **

In the case of C language

fgets(buf, 30, stdin);

You can read strings from standard input including spaces, but Golang has some documents (this and [this](https:: //qiita.com/zurazurataicho/items/e66645bac16d9a482369) or this) It's quite difficult for beginners.

Meanwhile, I felt that this was good for beginners.

It's quite difficult ...

Summary

Currently, we are translating C language to Golang, so we plan to release it from the translated program.

Recommended Posts

Notes on standard input / output of Go
Standard input / output summary
Part 1 of receiving standard input
Tips on Python file input / output
Notes for Python file input / output
Input / output method of values from standard input in competitive programming, etc.
UnicodeEncodeError struggle with standard output of python3
[Python] Chapter 02-03 Basics of Python programs (input / output)
[Python] Standard input
Notes on Flask
Standard input summary
Notes and Tips on Vertical Joining of PySpark DataFrame
Receives and outputs standard output of Python 2 and Python 3> C implementations
Notes on neural networks
Celery notes on Django
Notes on installing PycURL
python input and output
Python audio input / output
Theme: Standard output [Difficulty ★★★★★]
Limited standard output problem
Features of Go language
[Python] About standard input
Basics of python: Output
Notes on using Alembic
Notes on SciPy.linalg functions
Notes on handling large amounts of data with python + pandas
[For beginners] Summary of standard input in Python (with explanation)
Notes on python personally used things (input, trigonometric functions, logarithms)
Coordination of each process in MPI and buffering of standard output