Challenge

Write a function called spaceCount() that counts the space characters (ASCII 0x20) in a C string. Test it like this:

#​i​n​c​l​u​d​e​ ​<​s​t​d​i​o​.​h​>​

i​n​t​ ​m​a​i​n​ ​(​i​n​t​ ​a​r​g​c​,​ ​c​o​n​s​t​ ​c​h​a​r​ ​*​ ​a​r​g​v​[​]​)​
{​

 ​ ​ ​ ​c​o​n​s​t​ ​c​h​a​r​ ​*​s​e​n​t​e​n​c​e​ ​=​ ​"​H​e​ ​w​a​s​ ​n​o​t​ ​i​n​ ​t​h​e​ ​c​a​b​ ​a​t​ ​t​h​e​ ​t​i​m​e​.​"​;​
 ​ ​ ​ ​p​r​i​n​t​f​(​"​​"​%​s​​"​ ​h​a​s​ ​%​d​ ​s​p​a​c​e​s​​"​,​ ​s​e​n​t​e​n​c​e​,​ ​s​p​a​c​e​C​o​u​n​t​(​s​e​n​t​e​n​c​e​)​)​;​

 ​ ​ ​ ​r​e​t​u​r​n​ ​0​;​
}​

Remember: when you run into '', you have reached the end of the string!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset