Logo

Programming-Idioms

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

Idiom #120 Read integer from stdin

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

my $n = <> + 0;  # read a line from STDIN, add 0 to convert to int
#include <stdio.h>
int n;
scanf("%d", &n);

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