Can anyone tell me why I am getting an error
Code:
// isbnreader123.cpp : main project file.
#include "stdafx.h" //visual studio
#include <stdio.h> // printf scanf
#include <ctype.h> // tolower
#include <string.h> // strlen
#include <stdlib.h> // isdigit atoi
#include <process.h> // system()
void hello(void); //program to welcome user
char is_valid (char vaild_y_n); // checks for yes or no to continue program
int is_valid_isbn (char isbn[]); //function to check for non numeric input within ISBN
int check_digit_calc(void); //calculates check digit
char isbn[13]; //array for ISBN (character string)
int isbn_num[13]; //array for ISBN (numeric)
int main()
{
char y_n = 'y'; //sentinel
int i, chk_valid, last_digit; // i=for counter, chk_vaild= switch, last dig= calculated last isbn digit
hello(); //function call
while(y_n =='y')
{
printf("\n\n Please enter you ISBN number");
scanf("%s",isbn); //reads isbn into character string isbm[]
chk_valid = is_valid_isbn(isbn); //calls function to check for valid isbn
if(chk_valid==1)
{
last_digit = check_digit_calc(); //recives calculated last digit
if(isbn_num[9]==last_digit)
printf(" \n\n The ISBN is valid\n\n");
else
printf("\n\n You have entered an invalid ISBN \n\n");
}
else
printf("\n\n The ISBN you have entered contained non-numeric characters!\n\n");
printf("Do you wish to enter another ISBN number ?");
scanf("%c",&y_n);
y_n=is_valid(y_n); //checks is user wants to continue
system("cls");
}
return 0;
}
void hello(void) //function to greet user
{
printf("\n *** Welcom to the ISBN check digit program where you enter and ISBN and we check it *****\n");
printf("\n ****How cool is that\a\..........**\n");
printf("\n **** Save your applause for after ****\n");
}
char is_valid(char valid_y_n)
{
valid_y_n = tolower(valid_y_n);
while(valid_y_n != 'y'&& valid_y_n != 'n')
{
printf("You can only enter 'y' or 'n'");
scanf("%c",&valid_y_n);
valid_y_n = tolower(valid_y_n);
}
return (valid_y_n);
int is_valid_isbn(char isbn[])
{
int i, //counter loop
j=0, //index for array
invalid=1 ;
char isbn_num1[1]; //singal digit string for atoi
char *ptr_num1; // pointer for atoi
ptr_num1 = &isbn_num1[0]; //initialization of pointer for atoi
for (i = 0; i<strlen(isbn);i++) //loop to contiune to the end of the string
{
if(isbn[i] != '-') //gets rid of the hyphens and ignores them
{
if(isdigit(isbn[i]) == 0) //fail
invalid = 0; //switch for main()
else
{
isbn_num1[0] = isbn[i]; //stores characters as a string
isbn_num[j] = atoi(ptr_num1); // stores characters in a form atoi() can use
j++;
}
}
}
return(invalid);
int check_digit_calc(void) //calculates check digit
{
int k, digit_total = 0,
digit_value = 0;
for( k = 0; k < 9; k++)
digit_total += (k+1)* isbn_num[k];
digit_value = digit_total % 11;
return (digit_value);
}