how to print error for excess variables

im writing a barcode program using C and have the following so far done:
#include
int main(void) {

int b1;
int b2;
int b3;
int b4;
int b5;
int b6;
int b7;
int b8;
int b9;
int b10;
int b11;
int b12;
int c1;


printf("please enter barcode:
");
scanf("%1d", &b1);
scanf("%1d", &b2);
scanf("%1d", &b3);
scanf("%1d", &b4);
scanf("%1d", &b5);
scanf("%1d", &b6);
scanf("%1d", &b7);
scanf("%1d", &b8);
scanf("%1d", &b9);
scanf("%1d", &b10);
scanf("%1d", &b11);
scanf("%1d", &b12);
scanf("%1d", &c1);
printf("%d%d%d-%d%d%d%d%d%d-%d%d%d-%d.
" ,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,c1);

firstly is there an easier way of doing this ie. getting input from user and arranging it in the from 111-111111-111-1? without using functions, strings or arrays (throughout the program).
and i also would like to know how to print an error message if the input exceeds 13 integers or is less then 12 integers.

if anyone could help that would be much appreciated. i don't really no much C, pretty much self teaching.
thank-you.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories