Design a C program the embed special character as leading and trailing to the input string and display the output.
#include <stdio.h>
#include <string.h>
int main()
{
char strings[1000];
int i,j;
printf("Enter the string :");
gets(strings);
printf("Before trimming leading and trailing white spaces :'%s'",s);
for(i=0;strings[i]==' '||strings[i]=='\t';i++);
for(j=0;strings[i];i++)
{
strings[j++]=strings[i];
}
strings[j]='\0';
for(i=0;strings[i]!='\0';i++)
{
if(strings[i]!=' '&& strings[i]!='\t')
j=i;
[j+1]='\0';
printf("\nAfter trimming leading and trailing white spaces :'%s'",strings);
}
Comments
Leave a comment