fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C/C++.
  5. Code, Compile, Run and Debug online from anywhere in world.
  6.  
  7. *******************************************************************************/
  8. /*
  9. NAME : Brian J Peter
  10. SECTION : B
  11. UNIVERSITY R.NO : 2018766
  12. ROLL NO : 16
  13. PRG 1 : Write a program to insert a Sub-String into a String from particular position.
  14. */
  15.  
  16. # include<stdio.h>
  17. #include<string.h>
  18. void main() {
  19.  
  20. char str[100],str2[20];
  21. int n,i,l1,l2,j;
  22. printf("\t\t\t*******INPUT******* \n");
  23. printf("Enter the String : \n");
  24. gets(str);
  25. printf("Enter the Sub-String : \n");
  26. gets(str2);
  27. printf("Enter the position from where you want to enter Sub-String : \n");
  28. scanf("%d", &n);
  29. l1=strlen(str);
  30. l2=strlen(str2);
  31. for(i=0; i<l2; i++)
  32. {
  33. for(j=l1; j>=(n-1); j--)
  34. {
  35. str[j+1]=str[j];
  36. }
  37. str[n-1]=str2[i];
  38.  
  39. l1++;
  40. n++;
  41. }
  42. printf("\t\t\t*******OUTPUT******* \n");
  43. puts(str);
  44.  
  45. }
  46.  
Success #stdin #stdout 0s 5472KB
stdin
45
stdout
			*******INPUT******* 
Enter the String : 
Enter the Sub-String : 
Enter the position from where you want to enter Sub-String : 
			*******OUTPUT******* 
R[�