Every other word

Pages: 12
Well, there is a mistake:
 
if(i > length) break;

It can give you some problems: This is the correct way:
 
if(i >= length) break;

You can also use, in that while,
 
while (str[i] != ' ' && i < length) // ... 
ask user to input a sentence
create a boolean variable for tracking the spaces
for each character in the string
----if the character is a space
--------toggle the boolean variable
----otherwise, if the boolean variable is true
--------set the character to a star
print resulting string
Last edited on
Topic archived. No new replies allowed.
Pages: 12