Need help with this problem

Required a function of int string(char* s, int size), which returns 1 if the sequence of characters pointed to by sequence consists of only the characters A, B, and C, and otherwise returns 0. size is the size of array input by user.

Recommended Answers

All 2 Replies

Start at the first character. If it is something other than A,B, or C, return 0. Otherwise, go on to next character and repeat. I'll leave it to you to work out how many times you repeat. When you've checked them all, return 1.

Well you will need a for loop for starters to work your way through the array, and then an if statement to compare if the characters match A, B or C. Give it try and see how far you get

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.