main.c
#include <stdio.h>
int main() {
int k;
scanf("%d", &k);
return 0;
}
main.go
package main
import "fmt"
func main() {
var n int
fmt.Scan(&n)
}
root@82da6559c1c0:/code# go run main.go
123x123
root@82da6559c1c0:/code# 123
bash: 123: command not found
root@82da6559c1c0:/code# gcc main.c -o main
root@82da6559c1c0:/code# ./main
123x123
root@82da6559c1c0:/code#
I want to konw why in Golang,
123
was inserted into my bash command. But in C it didn't? Was there any differecces? (I konw there were some characters remained in stdin)I want to konw how can I make Golang behave like C does?