Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Scala

Idiom #120 Read integer from stdin

Read an integer value from the standard input into the variable n

import scala.io.StdIn
import scala.util.Try
val n = Try(StdIn.readInt())
#include <stdio.h>
int n;
scanf("%d", &n);

New implementation...
< >
programming-idioms.org