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
Write a Python statement that displays the value referenced by the number variable formatted as1,234,567.5
bulgar [2K]

Answer:

x = 1234567.5

print(f'{x:,}')

* there's various ways to accomplish this, but above seems to be the shortest. Requires python ≥ 3.6

8 0
3 years ago
Najbardziej znane przeglądarki internetowe
grin007 [14]

What is the question?????


4 0
3 years ago
Read 2 more answers
The first place you should look for specific guidance on how to maintain your vehicle is
erica [24]

Answer: the instruction manual

Explanation: i dont take this course, so this is just my common knowledge

5 0
3 years ago
Read 2 more answers
What is presentation software in bussiness used for
Andreas93 [3]

Answer:

Presentation software is a category of application software that is specifically designed to allow users to create a presentation of ideas by stringing together text, images and audio/video.

Explanation:

7 0
2 years ago
After class, Anita and Bev make plans to study for their psychology exam together but cannot decide on a time or location. In ad
jarptica [38.1K]

Answer:

The answer to this question is the option "a".

Explanation:

In this question, the answer is "a second or less". because Anita will not be unable to retain her information in short-term memory, without additional processing and they both decide to meet at Bev's dorm so he will give his room number(room-id) and pass-code to Anita.that's why the answer to this question is option a.

8 0
3 years ago
Other questions:
  • Which type of navigation involves multiple frames that are linked to a number of other frames?
    9·1 answer
  • Ryan is looking at investment opportunities as a cloud service provider. He wants to invest in a deployment-based cloud model th
    11·2 answers
  • How can you take a picture of work on here?????
    9·1 answer
  • 7. Which innovation in video games do you think has been most significant? Include at least one way that innovation affects the
    6·1 answer
  • With microprocessors, The integration of a whole _____ onto a single chip or on a few chips greatly reduced the cost of processi
    14·1 answer
  • Create a 4x5 matrix with ones everywhere and zeros on the last row.
    14·1 answer
  • Suppose you have the following declaration.int[] beta = new int[50];Which of the following is a valid element of beta.(i) beta[0
    14·1 answer
  • Cuales son las caracteristicas de los celulares
    9·1 answer
  • An open intersection is one that
    9·2 answers
  • Which of the following is true?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!