Q:

C Program to replace the spaces of a string with a specific character

0

C Program to replace the spaces of a string with a specific character

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
#include<ctype.h>

int main()
{
	int new_char;
	char t;
	int ctr=0;
	char str[100]; 
	    
    printf(" Input a string : ");
	fgets(str, sizeof str, stdin); 
    printf(" Input replace character : ");
	scanf("%c",&t);
	printf(" After replacing the space with  %c the new string is :\n",t);
	while (str[ctr])
	{
		new_char=str[ctr];
		if (isspace(new_char)) 
		new_char=t;
		putchar (new_char);
		ctr++;
	}
	printf("\n\n");
	return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now