// filename:c2011-5-1-2-3-ex7a.c
// original examples and/or notes:
// 		(c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
// 			C2011 5.1.2.3 Program execution, Example7
// compile and output mechanism:
// 		(c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.xx, 2013
// compile errors and/or wornings:
// 1	(c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
// 			Target: x86_64-apple-darwin11.4.2 //Thread model: posix
// 		(c) LLVM 2003-2009 University of Illinois at Urbana-Champaign.
// 2    gcc-4.9 (GCC) 4.9.0 20131229 (experimental)
//      Copyright (C) 2013 Free Software Foundation, Inc.
#include <stdio.h>
#define BUF 20
int main(void){
	int sum=0,i,tmp;
	char p[BUF];
	/* ... */
	for (i=0; i<BUF && (tmp=getchar()) != '\n' && tmp!=EOF; i++){
		if (tmp >= '0' && tmp <= '9')	p[i] = tmp; else p[i] = '0';
		}
	sum = sum * 10 - '0' + p[i-2];
	printf(" %d %c ", sum, p[i-2]);
	sum = ((sum * 10) - '0') + p[i-1];
	return printf("%d %c \n5.1.2.3 Program execution, Example7\n",sum,p[i-1]);
}
// if input is
// 123
// then output will be 
// 2 2 23 3 
//5.1.2.3 Program execution, Example7
