sarah sturgeon wrote:But compiler kept giving error.
Please, in the future, tell us exactly what the error says. Believe it or not, those error messages tell you a LOT about what the problem is. Learning how to read them is a valuable skill that will save you hours of time in the future.
Simply saying "i get an error" is often meaningless. There are too many things it could be for anyone to give you any real help (most of the time).
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors