Thanks for the indentation tip, I haven't gotten to the "Indentation" chapter of the tutorial sets yet (and there actually is one, so I can see its importance). This is only my 4th or 5th program. I knew indenting was important, but wasn't sure on exactly how the style should look. So, thanks for the example.
Let me be more clear. I'm really confused about how to get each character is a string, say: "12345" to be assigned to to an integer array. Some on this forum hinted that doing this will involve subracting zero.
Code:
isbn_string[b]= 0 - isbn_dec[a];
This was one of the many pathetic trial and error attempts I made before realizing I must be missing some key information and knowledge here and came back to the forum. The above code is simply a relic of my experiments (which has been extremely helpful, if odd looking to a veteran)
The entire last section of the program are my attempts to get each character of the string, into its own int, then multiply each char by its placement number in the string. i.e. string: 5467, will have 5*1, 4*2, 6*3 etc.
Code:
#include<stdio.h>
#include <windows.h>
int main()
#define MAX 10
/* fill the first aray with their space numbers,
then print it to make sure*/
{
char isbn_string[10];
int a, b, c, x, y, z, isbn_dec[10];
for (a=0; a < 10; a++)
{
isbn_dec[a]=a;
printf("%d\n",isbn_dec[a]);
}
printf("\nPlease enter ISBN: ");
scanf("%s",isbn_string);
printf("\nisbn is now the string: %s",isbn_string);
/* So, right now, isbn is not an array of ints yet, its a
string. It needs to be copied 1 by 1 into an array of ints*/
for (b=0; b<10; ++b)
{
for (a=0; a<10; ++a)
for (y=1; y<=10; ++y)
/* Code below will not attempt to attach each string char to
an array of ints*/
isbn_string[b]= 0 - isbn_dec[a];
isbn_dec[a] = y;
/* Code below attemps to multiply the string char, now turned int
by the its placement number in the string, then printf the result.
i.e. string: 5467, will have 5*1, 4*2, 6*3 etc */
z = isbn_string[b] * isbn_dec[a] ;
printf("\n%d", z);
}
getch();
return 0;
}
Thank you for you patience. I know from teaching other subjects that a noob's ignorance and lack of knowledge can make you want to pull your hair out.