Rule #1: "It doesn't work" is not a useful problem description. Tell us what exactly went wrong (compiler errors, wrong output, ...)

Rule #2: Always compile with warnings turned on. Then you...