#include <iostream>
#include <string>
#include <sstream>
using namespace std ;
int main ()
{
char promptisbn [] = "Plese Enter 10 Digit ISBN" ;
string isbn ;
int x = 0 ;
char buffer[1024] ;
cout << promptisbn << endl ;
cin.getline ( buffer, sizeof(buffer), '\n') ;
isbn = buffer ;
for ( x=0 ; x < isbn.length() ; x++ )
if ( !isdigit(isbn[x]) && toupper(isbn[x]) != 'X')
{ printf("erasing: %c\n", isbn[x]) ;isbn.erase (x,1) ; --x ;}
cout << "You Entered: " << endl ;
cout << isbn << endl ;
int a, b , c , d , e , f , g , h , i , j ;
a = isbn[0] ;
b = isbn[1] ;
c = isbn[2] ;
d = isbn[3] ;
e = isbn[4] ;
f = isbn[5] ;
g = isbn[6] ;
h = isbn[7] ;
i = isbn[8] ;
j = isbn[9] ;
cout << a << endl ;
cout << b << endl ;
cout << c << endl ;
cout << d << endl ;
cout << e << endl ;
cout << f << endl ;
cout << g << endl ;
cout << h << endl ;
cout << i << endl ;
cout << j << endl ;
getchar () ;
}
I'm working on writing an ISBN validation program. I need to be able to access the individual values of the isbn string after it's been cleaned up. Right now when I output this I get as follows:
Please Enter 10 Digit ISBN
123456789X
You Entered:
123456789X
49
50
51
52
53
54
55
56
57
88
so the output is the address of where the values are... not the actual values in that block of memory.
What approach would I take to be able to access these values individually so I can continue with the homework and start doing arithmetic with them?