Back To C++ Single Dimensional Arrays Index
//program to input a string and replace each space with a hyphen(-) using for loop #include
#include
void main() { char str[20]; int i; clrscr(); printf("\nenter a string "); gets(str); for(i=0;str[i]!='\0';i++) { if(str[i]==' ') { str[i]='-'; } } printf("\nconverted string is %s",str); getch(); }