Inserting substring into mainstring

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
 int i,j,k=0,p,k1;
 char str1[100],str2[100],final[100];
 clrscr();
 printf("enter the main string:\n");
 gets(str1);
 printf("enter the substring:\n");
 gets(str2);
 printf("eneter the position:");
 scanf("%d",&p);
 for(i=0;i<p;i++)
 {
  final[i]=str1[i];
 }
 k=i;
 for(j=0;str2[j]!='\0';j++)
 {
 final[k]=str2[j];
 k++;
 }
 for(i=i;str1[i]!='\0';i++)
 {
 final[k]=str1[i];
 k++;
 }
 final[k]='\0';
 printf("final string is:%s\n",final);
 getch();
 }

Comments

Popular posts from this blog

C program to copy the contents of one file to another

Division of two complex numbers

Student marks by using structures