Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In C language, how to define the data type, variable definition and writing method of numeric string input starting with 0? For example, 0 123456, C language beginners ask questions ~
In C language, how to define the data type, variable definition and writing method of numeric string input starting with 0? For example, 0 123456, C language beginners ask questions ~
The number entered at the beginning of 0 is a positive integer in octal.

Input and output formats with %o

Considering the numerical range, variables are defined as long integers or integers.

Octal number, the number can be 1, 2, 3, 4, 5, 6, 7, 0, without 8 or 9.

# include & ltstdio.h & gt

# include & ltstdlib.h & gt

void main()

{

long int i,j,k; //Variables are defined as long integers or integers.

Printf ("Enter data in O-for example, 077 \ n");

scanf("%o ",& ampI); //Read in I in octal mode

k = I+ 1; // k is greater than I 1.

printf("%o\n ",k); //Print the octal value of k.

printf("%d %d ",I,k); //Print the decimal value of i, k.

Exit (0);

}

Enter i: 077 (or 77)

Print the octal value of k: 100.

Print the decimal value of I, k: 63 64

Enter i: 0 123456 (or 123456).

Print the octal value of k: 123457.

Print the decimal value of I, k: 42798 42799.