#include <stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char input[50], output[50];
int i = 0, j = 0, count = 0;
printf("Enter intput string \n");
gets(input);
printf("input string is %s \n",input);
count = strlen(input);
for(i = 0; i<count; i++)
{
if(input[i]=='_')
output[j] = ' ';
else
output[j] = input[i];
j++;
}
output[j] = '\0';
printf("output string is %s \n",output);
getch();
return 0;
}
Output :
C program to remove underscore and substitute it with white spaces in a string
#include<conio.h>
#include<string.h>
int main()
{
char input[50], output[50];
int i = 0, j = 0, count = 0;
printf("Enter intput string \n");
gets(input);
printf("input string is %s \n",input);
count = strlen(input);
for(i = 0; i<count; i++)
{
if(input[i]=='_')
output[j] = ' ';
else
output[j] = input[i];
j++;
}
output[j] = '\0';
printf("output string is %s \n",output);
getch();
return 0;
}
Output :