Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a function called copyCapitals that uses a pointer to copy all of the cap

ID: 3570792 • Letter: C

Question

Create a function called copyCapitals that uses a pointer to copy all of the capital letters from a CString to a character array. The copyCapitals function must take as arguments the CString to search, and a character array to put all of the capital letters in. The function should also return the number of capital letters copied.

You must use one while loop and one decision within that while loop to solve the problem. This is a question testing your knowledge of pointers and I can't give you any points if you use array notation (brackets).

For submission I only need the copyCapitals function.

Explanation / Answer

int copyCapital(char *s,char a[])
{
   int count=0,i=0;
   while(*s!='')
   {
       if(isupper(*s))
       {
       a[count]=*s;
       count++;
   }
       s++;
   }
   return count;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote