Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have some pseudo code of what the function needs to do but just cannot figure it out. This is in C. kstring kstrfrom(const char

I have some pseudo code of what the function needs to do but just cannot figure it out. This is in C.

kstring kstrfrom(const char *cstr)

Creates and returns a new kstring object that contains a copy of the contents of a null-terminated C string, including the null terminator.

The .length member of the returned kstring should be the length of cstr, plus one for the null terminator. The .data member should be a pointer to newly-allocated memory (using , into which you have copied the contents of cstr, including the null byte at the end.

If there is an error allocating memory, this function should call abort().

Could you please show how I need to call this in the main function and how to output an that value to the user. New to C and there are some differences between it and c++.

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

Excel caculation on cascade mental health clinic

Answered: 1 week ago