Isn't it a little silly to restrict the use of if statements but still allow loops?
You can throw a loop into a function then have the loop return and it's practically the same as an if:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
long int checkNum(const char * s)
{
long int n;
char * e;
/* Basically the same as if (!s) return -1 */
while (!s) {
printf("Enter a number\n");
return -1;
}
n = strtol(s, &e, 10);
while (errno == ERANGE) {
printf("Number is out of possible range\n");
return 0;
}
while (n == 0 && e == s) {
printf("Not a number\n");
return n;
}
return n;
}
int main(int argc, char ** argv)
{
long int i, n = checkNum(argv[1]);
for (i = 0; i < n; ++i)
putchar('*');
putchar('\n');
return 0;
}