Okay, then what you want requires a totally different plan. You need to manually parse each element of an array and see if it's a digit, if it is then you print it and if it isn't you break. I've written a little template for you to use, edit it however you need to to get the proper results.
int done = 0, i = 0;
fgets(department, sizeof(department), stdin);
done = 1;