Passing char to a function

if you indented the code in the IDE before copying (that's done by pressing ctrlT on a PC or cmdT on a Mac) you would see that it's not a suitable code (the loop is not there / missing brackets probably)