Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started