0% found this document useful (0 votes)
323 views1 page

Charaterstuffing

This C program performs character stuffing on a user-input string. The user enters a string, and starting and ending delimiter characters. The program inserts the starting delimiter before and ending delimiter after each character in the input string. It outputs the stuffed string. For the sample input "goodday" with starting delimiter "d" and ending delimiter "g", it produces the output "dggooddddayg".

Uploaded by

carieanil
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
323 views1 page

Charaterstuffing

This C program performs character stuffing on a user-input string. The user enters a string, and starting and ending delimiter characters. The program inserts the starting delimiter before and ending delimiter after each character in the input string. It outputs the stuffed string. For the sample input "goodday" with starting delimiter "d" and ending delimiter "g", it produces the output "dggooddddayg".

Uploaded by

carieanil
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<stdio.h> #include<conio.

h> main() { char a[30],fs[50]="",t[3],sd,ed,x[3],s[3],d[3],y[3]; int i,j,p=0,q=0; clrscr(); printf("Enter characters to be stuffed : "); scanf("%s",a); printf("\nEnter a character that represents starting delimiter : "); scanf(" %c",&sd); printf("\nEnter a character that represents ending delimiter : "); scanf(" %c",&ed); x[0]=s[0]=s[1]=sd; x[1]=s[2]='\0'; y[0]=d[0]=d[1]=ed; d[2]=y[1]='\0'; strcat(fs,x); for(i=0;i<strlen(a);i++) { t[0]=a[i]; t[1]='\0'; if(t[0]==sd) strcat(fs,s); else if(t[0]==ed) strcat(fs,d); else strcat(fs,t); } strcat(fs,y); printf("\nAfter stuffing : %s",fs); getch(); }

CHARACTER STUFFING OUTPUT Enter characters to be stuffed : goodday Enter a character that represents starting delimiter : d Enter a character that represents ending delimiter : g After stuffing : dggooddddayg

You might also like