Functions

I need to create a function that scans a string for the Character '-' and replaces it with '_'. I'm thinking that i should use strcpy but im not sure. help?

And also how would i create a function that tells the amount of words in a string. and how a word is defined needs to be stated also.

please help.

patrick
I need to create a function that scans a string for the Character '-' and replaces it with '_'. I'm thinking that i should use strcpy but im not sure. help?

http://www.cplusplus.com/reference/string/string/find/
http://www.cplusplus.com/reference/string/string/replace/


And also how would i create a function that tells the amount of words in a string. and how a word is defined needs to be stated also.

The only real way of defining whether or not a word is a word is by finding the spaces in a string that seperate sequences of characters. Take a look at: http://www.cplusplus.com/reference/clibrary/cstring/strtok/
Topic archived. No new replies allowed.