Hello, the function of this program is to read in a student id number and convert it into a format like ddd-dd-dddd. Where d represents any digit from 0 to 9. The program should be able to deal with id input as many times as the user wants. Using 0 ID to terminate the program. When the user enters a wrong ID, he/she should be allowed to re-enter an id.
How can i incorporate these things in the following program. What loops should I use, if any.
Thanxs

Here is my program:

#include<iostream.h>
#include<string.h>
#include<ctype.h>

// copy a part of string to another string
void copystring(char t[], const char s[], int p1, int p2);

// test if an input consists all digits
int all_digits(char s[], int size);

void main()
{ char ss_number_input[10] = "000000000",
number_1to3[4] = "000",
number_4to5[3] = "00",
number_6to9[5] = "0000",
ss_number_output[12] = "";


cout << "\nEnter your ss number in all digits: ";
cin >> ss_number_input;


if (all_digits(ss_number_input, 10)) {
// separate into 3 parts
copystring(number_1to3, ss_number_input, 1, 3);
copystring(number_4to5, ss_number_input, 4, 5);
copystring(number_6to9, ss_number_input, 6, 9);

// reorganize ss number with insertation of '-'
strcat(ss_number_output, number_1to3);
strcat(ss_number_output, "-");
strcat(ss_number_output, number_4to5);
strcat(ss_number_output, "-");
strcat(ss_number_output, number_6to9);

cout << "\nYour ss number is ";
cout << ss_number_output<<endl;
}
else
// a ss number should not have non-digit characters
cout << "\n Invaild ss number, Please try again..";

}

void copystring(char t[], const char s[], int p1, int p2)
{ int idx;

// p1: starting position
// p2: ending position
for (idx = 0; idx <= p2 - p1; idx++)
t[idx] = s[p1 + idx - 1];
t[idx] = '\0';
}

int all_digits(char s[], int size)
{ int idx;
char ch;

idx = 0;
ch = s[idx];
while (idx < size && ch != '\0' && isdigit(ch)) {
idx++;
ch = s[idx];
}

if (idx == 9)
return 1;
else
return 0;

}