Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help writing the function for this RME in C++ using c-strings! // REQUIRES: str1 and str2 point to C-strings // EFFECTS: If str1

I need help writing the function for this RME in C++ using c-strings!

// REQUIRES: str1 and str2 point to C-strings

// EFFECTS: If str1 and str2 contain exactly the same characters, returns 0.

// Otherwise, return a positive number if the first differing char // has a greater value in str1 than in str2 and a negative number in

// the opposite case (you may NOT call strcmp).

int strcmp(const char *str1, const char *str2)

{ So what I figured is that I have to compare the two strings, assuming they are the same length.

if (str1 == str2) { return 0; }

else { //somehow compare every letter and when the letters at the same index are not equal, return the difference of the letter in str1 - the letter in str2 so if str1 is greater it returns a positive number and a negative one if the differing letter in str1 is smaller than the one in str2. }

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

Step: 3

blur-text-image

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions