fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. char str[100];
  6. printf("Enter a string: ");
  7. gets(str) ; // read a string from the user
  8.  
  9. int len = strlen(str);
  10. for (int i = 0; i < len; i++) {
  11. if (str[i] == ' ') {
  12. str[i] = '*'; // replace white space with *
  13. }
  14. }
  15.  
  16. printf("Modified string: %s", str);
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 5436KB
stdin
i am 
stdout
Enter a string: Modified string: i*am*