Your cart is currently empty!
The Search for a Character Since you are reading this, you have already downloaded and extracted the zip file. 1.1 Tasks to do Take a look at the starter file. As you can see, a call is being made to the index function. This function should take in a character pointer (which is the starting…
The Search for a Character
Since you are reading this, you have already downloaded and extracted the zip file.
1.1 Tasks to do
Take a look at the starter file. As you can see, a call is being made to the index function.
This function should take in a character pointer (which is the starting location of a string). It should also take in a character as a parameter. The function should search for this character within that string.
If the character is found, it should return the index of that character (0-based)
If the character is not found, it should return -1
If the character is found more than once, it should return the index of the first occurrence
The second function you need to write is count_digits. This should again take in a character pointer (which is the starting location of a string) and count the number of digits in that string. Note that in ASCII, digits go from 48 to 57.
A strict requirement is that you cannot use the index operator – [] – to access the characters of the string in either of the functions. You must use a pointer and move that pointer to different characters within the string to perform search and count.
After you’re done making your code work, write down (read: assignment must be hand-written) the full declaration and definition of both the functions on a paper and submit that on or before the deadline. Late assignments (or soft copies) will not be accepted.
CS217 – OOP (Spring 2019 – Assignment: A01) Page 1 of 1