Question

which function in the string library can be used to combine two strings? strcmp strlen strcat...

which function in the string library can be used to combine two strings?
strcmp
strlen
strcat
combine
none
0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • string library function strcat is used to combine two strings

Program:

#include <stdio.h>
#include <string.h>
int main() {
  
char str1[25] = "Hello ";
char str2[] = "American";
printf(" string 1 : %s ",str1);
printf("\n string 2 : %s ",str2);
strcat(str1, str2); // concatenates str1 and str2 // the resultant string is stored in str1.
printf(" \n combine string : %s ",str1);
return 0;
}

Output:

----------------------------------------------

string 1 : Hello
string 2 : American
combine string : Hello American

-------------------------------------------------

Run Debug Stop Share Save {}Beautify Language C main.c *********** ************** 1 2 3 Online C Compiler. 4 Code, Compile, R

Add a comment
Know the answer?
Add Answer to:
which function in the string library can be used to combine two strings? strcmp strlen strcat...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 1 Which pre-written C function can be used to determine if two strings are the...

    Question 1 Which pre-written C function can be used to determine if two strings are the same? A) equals B) strcmp C) strlen D) strcpy E) None of the Above Question 2 The function below is most like which existing string function? int f(char a[ ]) {                int count = 0;                while (a[count] != ‘\0’)                               count++;                return count; } A) strcat B) strcmp C) strcpy D) strlen E) None of the Above Question 3 The function...

  • Please note that I cannot use the string library function and that it must be coded...

    Please note that I cannot use the string library function and that it must be coded in C89, thank you! Formatting: Make sure that you follow the precise recommendations for the output content and formatting: for example, do not change the text in the first problem from “Please enter a string of maximum 30 characters:” to “Enter string: ”. Your assignment will be auto-graded and any changes in formatting will result in a loss in the grade. 2.Comments: Header comments...

  • the function below is most like which function in the string library? void f(chara[],charb[]) { int...

    the function below is most like which function in the string library? void f(chara[],charb[]) { int i; for(i=0; i<=strlen(b); i++) a[i] = b[i]

  • Objectives: Use strings and string library functions. Write a program that asks the user to enter...

    Objectives: Use strings and string library functions. Write a program that asks the user to enter a string and output the string in all uppercase letters. The program should then display the number of white space characters in the string. You program should run continuously until the user enters an empty string. The program must use the following two functions: A function called count_spaces that counts the number of white spaces inside a string. int count_space(char str[]); which tell you...

  • Write a program thet uses the function strcmp() to compare two strings input by the user....

    Write a program thet uses the function strcmp() to compare two strings input by the user. The program should state whether the first string is less then, equal to, or greater then the second string 7. Write a program thet uses the function strcmp() to compare two strings input by the user. The program should state whether the first string is less then, equal to, or greater then the second string

  • 39) Which function accepts two strings as arguments, returns "True" if the first string contains the...

    39) Which function accepts two strings as arguments, returns "True" if the first string contains the second string, and otherwise returns "False"? None of the above Contains Append Substring Concatenate

  • What will the value of the string s1 after the following statements have been executed? strcpy(s1,...

    What will the value of the string s1 after the following statements have been executed? strcpy(s1, "computer"); strcpy(s2, "science"); if(strcmp(s1, s2) < 0){     strcat(s1, s2); } else{     strcat(s2, s1); } s1[strlen(s1) - 6] = '\0'; I know the answer is "Computers" but why? Can someone explain to me how to approach this problem?

  • you may not use any of the C-string library functions such as strlen(), strcpy(), strstr(), etc....

    you may not use any of the C-string library functions such as strlen(), strcpy(), strstr(), etc. You must write your own. You might consider writing helper functions to do tasks that many of these functions require, e.g. finding the last character of the string, and then use those helper functions where convenient. This function finds all instances of the char ‘target’ in the string and replaces them with ‘replacementChar’. It also returns the number of replacements that it makes. If...

  • In C Programming Language In this lab you will implement 4 string functions, two using array...

    In C Programming Language In this lab you will implement 4 string functions, two using array notation and two using pointers. The functions must have the signatures given below. You may not use any C library string functions. The functions are 1. int my strlen (char s ) - This function returns the number of characters in a string. You should use array notation for this function. 2. int my strcpy (char s [], char t I)- This function overwrites...

  • •Create a project in Visual Studio (C++) •Have a function that compares two C-Strings (similar to...

    •Create a project in Visual Studio (C++) •Have a function that compares two C-Strings (similar to strcmp) •Have a function that copies one string to another string (strcpy) •Have a function that returns a persons first name only •I enter Bobby Loneker to the system, this function should cut my last name off •Have a function that returns a C-string backwards •I enter Bobby to the system it returns: ybboB

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT