Here is the code I have so far. Am I even going about this the right way?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define SIZE 10 /* size of array */
int verify (char* value) /* this function will verify the input is a number*/
{
int iChars = strlen (value);
int i;
for (i=0; i<iChars; i++) {
if (! isdigit (value [i])) {
return 0; /*Not a number*/
}
return 1; /*Is a number*/
}
}
int main()
{
int i, arr[SIZE], sum, average;
char temp[50];
/* get the numbers */
printf("Enter 10 numbers: \n");
for (i=0; i<SIZE; ++i)
scanf("%d",&arr[i]);
if (i<=0) {
exit(1);
}
SIZE=atoi(temp); /*convert char to int and verify*/
if (! verify (temp)) {
printf("\nYou did not enter a number, This program will now exit\n");
getchar();
exit(0);
}