Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A6E1 (4 points-C Program Exclude any existing source code files that may already be in your IDE project and a naming them CIA6E1-MyStrien.c and CIAGE1

image text in transcribed
A6E1 (4 points-C Program Exclude any existing source code files that may already be in your IDE project and a naming them CIA6E1-MyStrien.c and CIAGE1 main.c . Do not use files in each other or in any other file. However, you may use it to include any appio dd two new ones # include to include either of these appropriate header file(s) you need File ClA6E1 M IDE' s hel yStrlen.c must contain a function named MyStrlen that has the same syntax and the standard library strlen function. If you aren't familiar with strlen look it up in your have the syntax return a count of the number of characters in the string in s1, not including the null terminator IDE's help, the course book, any good C textbook, or online. MyStrlen must (prototype): size t MyStrlen(const char "s1); 1. 3. use only one variable other than its formal parameter s1. That variable must be of type "const pointer to const char" and must be initialized to the value of formal parameter s1 when declared, for example: const charconst START s1; 4. not call any functions, use any macros, or display anything: s. not use the sizeof operator (it wouldn't help anyway). File ClA6E1_main.c must contain function main, which must: 1. prompt the user to enter a string (which may be empty or contain spaces: 2. call strlen to determine that string's length; 3. call MyStrlen to determine that string's length 4. display the string and its length as determined by both strlen and MyStrlen in the following 2-line format, where ABC is the string used in this example and where the question marks represent the integral decimal numeric values returned by the functions. By sure to enclose the string in double quotes: strlen("ABC") returned? MyStrlen("ABC) returned? Manually re-run your program several times, testing with at least the following 4 strings (the last string is empty) 2. HELLO 3. C/C++ Programming I 4. (an empty string) Submitting your solution Send your two source code files to the Assignme your 9 character UCSD student ID See the course formatting, submission, and Assignment Checker requirements nt Checker with the subject line C1A6E1 ID, where ID is document titled "Preparing and Submitting Your Assignments" for additional exercise Hints: know what size t is? If not consider reviewing note 2.12. Do you know what pointer subtraction If not consider reviewing note 6.14. For an example of using a pointer to walk through a string see notes 6.17 and 7.2. No special case is needed for an empty string. Set the extra pointer variable you lowed to declare equal to the parameter pointer variable then increment one of these pointers as you step through the input string looking for the null terminator subtract the two point character, .er when you find it. ers to find the string length and return that difference. Type cast the return to size_ t to avoid a compiler warning. Most library functions that compute values, including strlen, do no printing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

State the purpose of a standard cost sheet.

Answered: 1 week ago