Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

cpp , cannot include any includes besides xps . h ( which is this file ) / / Compare two XP strings asciibetically. / /

cpp, cannot include any includes besides xps.h (which is this file)
// Compare two XP strings "asciibetically."
// Return a negative number if lhs comes before rhs.
// Return a positive number if lhs comes after rhs.
// Return zero if the two strings are equal.
int xps_compare(const char* lhs, const char* rhs);
// Create a new XP string that holds the concatenation of two XP strings.
// The new string should contain all the characters
// from lhs followed by all the characters from rhs.
char* xps_concat(const char* lhs, const char* rhs);
// Find a substring inside another XP string.
// If the substring is found, return the index of the first (leftmost) match.
// If the substring is not found, return XPS_NPOS (see below).
// If the substring is empty, it matches at any index.
// If a start index is given, only consider matches occuring
// at or to the right of that index.
size_t xps_find(const char* str, const char* substr);
size_t xps_find(const char* str, const char* substr, size_t start);
// Release the memory used to hold an XP string.
// After calling this function, the memory pointed
// to by str should no longer be used.
void xps_free(char* str);
// Create a new XP string from a C string.
// The new string should contain all the characters
// from the C string, but stored in the XPS format.
char* xps_from_cstr(const char* cstr);
// Get a single character from an XP string.
// This function should not perform bounds checking;
// assume the provided index is always in bounds.
char xps_getchar(const char* str, size_t index);
// Get the length of an XP string.
size_t xps_length(const char* str);
// Set a single character in an XP string.
// Like xps_getchar(), this function should not perform
// bounds checking; just assume that index is valid.
void xps_setchar(char* str, size_t index, char c);
// Get a substring of an XP string as a new XP string.
// The new string should contain all the characters from str starting at
// index start and up to but not including the character at index stop.
// If stop is not given, the new string should contain all the characters
// from index start until the end of the original string.
// If stop is past the end of the original string, only include characters
// up to the end of the original string; if start is past the end of the
// original string, or if stop is less than or equal to start,
// return an empty string.
char* xps_slice(const char* str, size_t start);
char* xps_slice(const char* str, size_t start, size_t stop);

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

Students also viewed these Databases questions

Question

Why has the Internet lowered the switching costs for consumers?

Answered: 1 week ago