SlideShare a Scribd company logo
S1-4
#include<stdio.h>
#include<conio.h>
Write a program to concatenate two strings S1 and S2.
#include<string.h>
void main()
{
char *s1, *s2, *s3;
int len, len1,len2, i, j;
clrscr();
s1=(char*)malloc(20);
s2=(char*)malloc(20);
printf("Enter first stringn");
gets(s1);
len1=strlen(s1);
printf("Enter second stringn");
gets(s2);
len2=strlen(s2);
len=len1+len2;
s3= (char*)malloc(len+2);
for(i=0;i<len1;++i)
*(s3+i) =*(s1+i);
*(s3+i)=' '; /*leave a space at end of first string */
++i;
for(j=0;j<len2;++j)
{ *(s3+i)=*(s2+j);
++i;
}
*(s3+i)='0'; /* store '0' at end to set 'end of string' */
printf("Concatenated string isn%s", s3);
getch();
}
Page 1

More Related Content

What's hot (20)

PDF
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s3-3
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s5-3
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s3-2
Dr. Loganathan R
 
PDF
Implement a queue using two stacks.
Dr. Loganathan R
 
PPTX
งานนำเสนอ อาจารย์ลาวัลย์
น้ำตาล มาแล้วจ้า
 
PDF
Dfs implementation in c
HapPy SumOn
 
PPTX
Function basics
mohamed sikander
 
PDF
Bcsl 033 data and file structures lab s4-2
Dr. Loganathan R
 
PDF
please sir i want to comments of every code what i do in eachline . in this w...
hwbloom27
 
DOCX
C++ 4
Syed Umair
 
PPTX
Double linked list
Sayantan Sur
 
PDF
Bcsl 033 data and file structures lab s3-1
Dr. Loganathan R
 
DOC
Add digits of number in c
mohdshanu
 
PPTX
C Programming Language Part 11
Rumman Ansari
 
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s5-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-2
Dr. Loganathan R
 
Implement a queue using two stacks.
Dr. Loganathan R
 
งานนำเสนอ อาจารย์ลาวัลย์
น้ำตาล มาแล้วจ้า
 
Dfs implementation in c
HapPy SumOn
 
Function basics
mohamed sikander
 
Bcsl 033 data and file structures lab s4-2
Dr. Loganathan R
 
please sir i want to comments of every code what i do in eachline . in this w...
hwbloom27
 
C++ 4
Syed Umair
 
Double linked list
Sayantan Sur
 
Bcsl 033 data and file structures lab s3-1
Dr. Loganathan R
 
Add digits of number in c
mohdshanu
 
C Programming Language Part 11
Rumman Ansari
 

Viewers also liked (6)

PDF
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
PPT
Academic counselling in IGNOU S.Kishore
skishoredr1
 
PPTX
IgnouBCA
diwakar9903
 
DOCX
bank transaction system
Bhavika Pathak
 
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
Academic counselling in IGNOU S.Kishore
skishoredr1
 
IgnouBCA
diwakar9903
 
bank transaction system
Bhavika Pathak
 
Ad

More from Dr. Loganathan R (16)

PDF
Ch 6 IoT Processing Topologies and Types.pdf
Dr. Loganathan R
 
PDF
IoT Sensing and Actuation.pdf
Dr. Loganathan R
 
PDF
Ch 4 Emergence of IoT.pdf
Dr. Loganathan R
 
PDF
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
 
PPT
Introduction to Information Security
Dr. Loganathan R
 
PDF
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Dr. Loganathan R
 
PDF
Session 9 4 alp to display the current system time using dos int 21 h
Dr. Loganathan R
 
PDF
Session 9 1 alp to compute a grade using procedures
Dr. Loganathan R
 
PDF
IGNOU Assembly Language Programming
Dr. Loganathan R
 
PDF
Requirement engineering process
Dr. Loganathan R
 
PDF
MCS 012 computer organisation and assembly language programming assignment…
Dr. Loganathan R
 
PDF
Software requirements
Dr. Loganathan R
 
PDF
Software process
Dr. Loganathan R
 
PDF
Software engineering critical systems
Dr. Loganathan R
 
PDF
Software engineering socio-technical systems
Dr. Loganathan R
 
PDF
Software engineering introduction
Dr. Loganathan R
 
Ch 6 IoT Processing Topologies and Types.pdf
Dr. Loganathan R
 
IoT Sensing and Actuation.pdf
Dr. Loganathan R
 
Ch 4 Emergence of IoT.pdf
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
 
Introduction to Information Security
Dr. Loganathan R
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Dr. Loganathan R
 
Session 9 4 alp to display the current system time using dos int 21 h
Dr. Loganathan R
 
Session 9 1 alp to compute a grade using procedures
Dr. Loganathan R
 
IGNOU Assembly Language Programming
Dr. Loganathan R
 
Requirement engineering process
Dr. Loganathan R
 
MCS 012 computer organisation and assembly language programming assignment…
Dr. Loganathan R
 
Software requirements
Dr. Loganathan R
 
Software process
Dr. Loganathan R
 
Software engineering critical systems
Dr. Loganathan R
 
Software engineering socio-technical systems
Dr. Loganathan R
 
Software engineering introduction
Dr. Loganathan R
 
Ad

Recently uploaded (20)

PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 

Bcsl 033 data and file structures lab s1-4

  • 1. S1-4 #include<stdio.h> #include<conio.h> Write a program to concatenate two strings S1 and S2. #include<string.h> void main() { char *s1, *s2, *s3; int len, len1,len2, i, j; clrscr(); s1=(char*)malloc(20); s2=(char*)malloc(20); printf("Enter first stringn"); gets(s1); len1=strlen(s1); printf("Enter second stringn"); gets(s2); len2=strlen(s2); len=len1+len2; s3= (char*)malloc(len+2); for(i=0;i<len1;++i) *(s3+i) =*(s1+i); *(s3+i)=' '; /*leave a space at end of first string */ ++i; for(j=0;j<len2;++j) { *(s3+i)=*(s2+j); ++i; } *(s3+i)='0'; /* store '0' at end to set 'end of string' */ printf("Concatenated string isn%s", s3); getch(); } Page 1