1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sineoko [7]
3 years ago
15

Mix ‘em Let s1 and s2 be 2 c-strings of the same length. Write a function char* mixem(char*s1, char* s2) which returns a c-strin

g made up of the characters of s1 and s2 "interleaved", starting with the first character of s1. Example: S1="abc", s2="123" The call mixem(s1,s2) returns the c-string "a1b2c3" Note: If s is a c-string, strlen(s) returns the length of the string (not counting the terminating null character ‘\0’.) Every c-string has a null character at the end.
Computers and Technology
1 answer:
Shkiper50 [21]3 years ago
5 0

Answer:

See Explaination

Explanation:

#include <iostream>

#include <string.h>

using namespace std;

char *mixem(char *s1, char *s2);

int main() {

cout << mixem("abc", "123") << endl;

cout << mixem("def", "456") << endl;

return 0;

}

char *mixem(char *s1, char *s2) {

char *result = new char[1 + strlen(s1) + strlen(s2)];

char *p1 = s1;

char *p2 = s2;

char *p = result;

while (*p1 || *p2) {

if (*p1) {

*p = *p1;

p1++;

p++;

}

if (*p2) {

*p = *p2;

p2++;

p++;

}

}

*p = '\0';

return result;

}

You might be interested in
What is your favorite film and what makes it good?
Gala2k [10]

Answer:

My Favorite film is The Old Guard

Explanation:

I like The Old Guard because it has action an etc.

4 0
2 years ago
Read 2 more answers
What is a list of data organized for easy access?
ozzi

Answer:

An Array

Explanation:

Array and Object is a good use for storing data and accessing it

6 0
2 years ago
Ignore this it a temporary note for me: SPSstudents
Westkost [7]

Answer:

okk

Explanation:

3 0
1 year ago
What is missing in this list of information needed to cite a book?
balandron [24]

Answer:

<h3><em><u>C</u></em><em><u>.</u></em><em><u> </u></em><em><u> </u></em><em><u>City</u></em><em><u> </u></em><em><u>and</u></em><em><u> </u></em><em><u>state</u></em><em><u> </u></em><em><u>where</u></em><em><u> </u></em><em><u>it</u></em><em><u> </u></em><em><u>was</u></em><em><u> </u></em><em><u>published</u></em></h3>

Explanation:

<h3>#CarryOnLearning</h3>

{hope it helps}}

4 0
2 years ago
Create a program that has at least three classes. The class with main. A class that defines a Name (first name, middle name, and
Bond [772]

Answer:

See attached file for complete detailed code.

Explanation:

See attached file.

Download txt
3 0
3 years ago
Other questions:
  • Write a program to read as many test scores as the user wants from the keyboard (assuming at most 50 scores). Print the scores i
    13·1 answer
  • What is computer ????
    11·1 answer
  • HEY DO U LIKE TRAINS!
    7·1 answer
  • Convert each of the following for loops into an equivalent while loop. (You might need to rename some variables for the code to
    10·1 answer
  • At what depth does an employer need to use a protection system to ensure the safety of workers in a trench or excavation?
    8·2 answers
  • The___provides access to the internet; may also be internal
    11·1 answer
  • Which of these is an expansion slot type?
    5·1 answer
  • Consider an array inarr containing atleast two non-zero unique positive integers. Identify and print, outnum, the number of uniq
    10·1 answer
  • Leo needs to consolidate data in multiple worksheets by performing a calculation across all worksheets on the same cells.
    12·2 answers
  • List and discuss five economic growth indicators
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!