Computer Science, asked by vishalrathaur70, 1 year ago


Using “pointers" concept write a program in C to allow to input 2 strings of user's
choice, concatenate them and display the length of the resultant concatenated
string.

Answers

Answered by dorinamehmeti
1

Answer:

#include<stdio.h>

#include<conio.h>

void stcat(char *str1, char *str2);

int main();

{

char *str1, *str2;

clrscr();

printf ("\n\n\t ENTER THE FIRST STRING…:");

gets(str1);

printf("\n\n\t ENTER THE FIRST STRING…: ");

gets(str2);

stcat(str1,str2);

printf("\n\t THE CONCATENATED STRING IS…: ");

puts(str1);

getch();

}

void stcat (char *str1, char *str2)

{

int i = 0,len = 0;

while(*(str1+len)!="\0")

len++;

while(*(str2+i)!="\0")

{

*(str1+len) = *(str2+i);

i++;

len++;

}

*(str1+len) = "\0";

}

Explanation:

Similar questions