How do I count how many characters of a string are stored in an array?
For example:
1 2 3 4 5 6 7
|
int main()
{
char a[40] = "ABCDE";
char b[40] = "FGHIJ";
system("PAUSE");
}
|
Array a would be like this |A|B|C|D|E| | | | | |... <40 spots max>
Array b would be like this |F|G|H|I|J| | | | | |... <40 spots max>
I want to know how many spots in the array it used, so for example, array a has 5 spots and array b has 5 as well, so I know a[4] is the last box in the array ditto for b. So, i = 4.
What I'm basically trying to do is depending on how many how far in the array the characters went, I am going to do an addition problem like this:
ABCDE
FGHIJ+
-----
so lets say the value of E is 10 and the value of J is 5, I want to find them using i and work my way down. So, i = 4, then a[i]+b[i] = a[4]+b[4] = 10+5.
Get what I mean? I'm just basically counting the characters of a string that is being inputted into the array and storing that number into i.
Does anyone know how to do this?