#include "stdafx.h" void print(char * number, int len, int index) { if(index == len) { printf("%s\n",number); return; } for(int i=0;i<10;i++) { number[index] = '0' + i; print(number, len, index+1); } } int _tmain(int argc, _TCHAR* argv[]) { char num[4]=""; print(num,3,0); return 0; }