#include<stdio.h> #include<ctype.h> #include<conio.h> int main() { int new_char; char t; int ctr = 0; char str[100]; printf("\n Replace the spaces of a string with a specific character :\n"); printf(" Input a string:"); fgets(str, sizeof str, stdin); printf(" Input replace character : "); scanf_s("%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; }
new_char = t;
//outside the loop int count = 0; if (isspace(new_char)) { count++ new_char = t; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)