//C program to replace white spaces with underscore
// and to uppercase all characters in a string
#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 input string in uppercase \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]+32;
j++;
}
output[j] = '\0';
printf("output string is %s \n",output);
getch();
return 0;
}
Output :
C program to replace white spaces with hypens and to lowercase all characters in a string
// and to uppercase all characters in a string
#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 input string in uppercase \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]+32;
j++;
}
output[j] = '\0';
printf("output string is %s \n",output);
getch();
return 0;
}
Output :