Reading integers from standard input and writing to standard output, in various formatted output
Compiler: Visual C++ Express Edition 2005
Compiled on Platform: Windows XP Pro SP2
Header file: Standard
Additional library: none/default
Additional project setting: Set project to be compiled as C
Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)
Other info: none
To do: Reading integers from standard input and writing to standard output, in various formatted output
To show: How to read integers from standard input and write to standard output in various formatted output
// Reading integers in various format
#include <stdio.h>
int main(void)
{
int a, b, c, d, e, f, g;
printf("Reading integers from standard input, writing to standard output\n");
printf("------------------------------------\n\n");
printf("Enter seven integers separated by space: ");
// scanf("%d%i%i%i%o%u%x", &a, &b, &c, &d, &e, &f, &g);
scanf_s("%d%i%i%i%o%u%x", &a, &b, &c, &d, &e, &f, &g);
printf("The input displayed as decimal integers is: \n");
printf("%d %d %d %d %d %d %d\n", a, b, c, d, e, f, g);
// try different format specifier
printf("%d %i %i %i %o %u %x\n", a, b, c, d, e, f, g);
return 0;
}
Output example:
Reading integers from standard input, writing to standard output
------------------------------------
Enter seven integers separated by space: 7 1 3 2 4 6 5
The input displayed as decimal integers is:
7 1 3 2 4 6 5
7 1 3 2 4 6 5
Press any key to continue . . .