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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.