Write the following function without using the C++ string class or any functions in the standard...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write the following function without using the C++ string class or any functions in the standard library, including strlen(). You may use pointers, pointer arithmetic or array notation. Write the function firstNot In (). • The function has two parameters (str1, str2), both pointers to the first character in a C-style string. . You should be able to use literals for each argument. • The function searches through str1, trying to find a match for the first character inside str1 that does NOT appear inside str2. Return the index of the first character in str1 that does not appear inside str2. • Note that if all of the characters in strl appear in str2, then return the length of the C-String s1. (This will happen automatically if you write function correctly.) You can call the function like this: cout << firstNotIn("eieioh", "aeiou"); // prints 5 (the index of h) cout << firstNotIn("ZZZzyx", "aeiou"); // prints 0 (index of the first Z) In both of these cases, the function returns the index of the first character that is not in the set of vowels following it. Exam C++ Quick Reference Complete the following file: p1.cpp 1 #include <cstddef> // size_t for sizes and indexes 2 using namespace std; 3 ///////////////// WRITE YOUR FUNCTION BELOW THIS LINE 4 size_t firstNotIn(const char * s1, const char * s2) 5 { 6 7 8 9} 10 size_t result; // Add your code return result; Write the following function without using the C++ string class or any functions in the standard library, including strlen(). You may use pointers, pointer arithmetic or array notation. Write the function firstNot In (). • The function has two parameters (str1, str2), both pointers to the first character in a C-style string. . You should be able to use literals for each argument. • The function searches through str1, trying to find a match for the first character inside str1 that does NOT appear inside str2. Return the index of the first character in str1 that does not appear inside str2. • Note that if all of the characters in strl appear in str2, then return the length of the C-String s1. (This will happen automatically if you write function correctly.) You can call the function like this: cout << firstNotIn("eieioh", "aeiou"); // prints 5 (the index of h) cout << firstNotIn("ZZZzyx", "aeiou"); // prints 0 (index of the first Z) In both of these cases, the function returns the index of the first character that is not in the set of vowels following it. Exam C++ Quick Reference Complete the following file: p1.cpp 1 #include <cstddef> // size_t for sizes and indexes 2 using namespace std; 3 ///////////////// WRITE YOUR FUNCTION BELOW THIS LINE 4 size_t firstNotIn(const char * s1, const char * s2) 5 { 6 7 8 9} 10 size_t result; // Add your code return result;
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Write the following function as a linear differential equation system of rank 1 and find the solutions: x"' + tx" + 2tx' 5t4 = 0 - %3D
-
Write the following function in terms of unit step function: f (t) = { 3t, 0
-
Write a function that will return a full name string when passed a first name string, a middle name or initial string, and a last name string. If the middle initial is blank, there should be only one...
-
Darwin uses decision tree analysis in order to evaluate potential projects. The company has been looking at the launch of a new product which it believes has a 70 per cent probability of success. The...
-
Eva Proctor is a planner in an agency that handles a liquid detergent brand that competes with Levers Wisk. Eva is reviewing a history of the Wisk theme, Ring around the Collar. In its day, it was...
-
Go to the website www.cedarfair.com and click on Investors, then Investor Information, Financial Reports, and Annual Reports. Then click on 2017 Annual Report on 10-K to access the 2017 Form 10-K...
-
For each of the following situations, calculate a \(95 \%\) confidence interval for the mean ( \(\sigma\) known), beginning with the step, "Identify the critical value of \(z\)." X 50.00, X = 3.00 X...
-
Efficient securities market theory has long been under attack from behavioural finance, which draws on psychological theories of investor behaviour to explain why security prices do not always behave...
-
Write code for the same thing exactly; send me the code so I can run it and send me the output. This is for engineers who understand networking and programming; if you are not one, kindly do not...
-
For each of the following employees, calculate the Social Security tax for the weekly pay period described: For simplicity, all calculations throughout this exercise, both intermediate and final,...
-
An opamp is used as a buffer between the source and the load resistor R in the circuit as shown. The opamp must be able to supply at least what magnitude of current to ensure that V O ( t ) = V in (...
-
How does the formal system differ from the informal system? How does document analysis help you understand both?
-
Describe the main building blocks for the communication diagram and how they are represented on the model.
-
What kinds of events can lead to state transitions on a behavioral state machine?
-
How do you show that a temporary object is to go out of existence on a sequence diagram?
-
What is a dependency relationship? How do you identify them?
-
A 20-year, 10%, *1,000 bond that pays interest half-yearly is redeemable (callable] in twelve years at a buy-back (call) price of 1,150. The bond's current yield-to-maturity is 9.50% annually. You...
-
Before the latest financial crisis and recession, when was the largest recession of the past 50 years, and what was the cumulative loss in output over the course of the slowdown?
-
Charlie's Green Lawn Care is a cash basis taxpayer. Charlie Adame, the sole proprietor, is considering delaying some of his December 2012 customer billings for lawn care into the next year. In...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-7. Ivan sold the following securities during the year and received a Form 1099-B that...
-
Russell (age 50) and Linda (age 45) Long have brought you the following information regarding their income and expenses for the current year. Russell owns and operates a landscaping business called...
-
What are the numbers of observations in each of the five categories that rate the respondents level of job satisfaction?
-
Which of the seven store departments had the most customer visits, and what was this number?
-
How many individuals are in each of the five different credit card categories?
Study smarter with the SolutionInn App