the program keeps asking me to write (s) or (n). |
Do you mean
(y) or (n)
? I don't see anywhere in your code that asks for
(s) or (n)
.
Anyway, since you're learning C++, here are some issues with your code:
main ()
This is not C++ and it never ever has been. Whatever you're using to compile this is bad and you should throw it away and get a modern compiler for free.
clrscr();
This is non-standard. I can only assume you've included a non-standard header that you haven't shown us. Please show all such code in the future.
char ans1[15];
Whilst not wrong, this is C++, and in C++ we use string objects.
ans2!="y"
This shows a fundamental misunderstanding of what you're doing. Here, I suspect you think you are comparing the character you typed in with the character y. You are not; you are comparing a char pointer with another char pointer.
if (ans2=="s")
So hold on, you just told the user to enter either y or n, and now you're immediately testing to see if the letter is s? But you just told the user to enter y or n. What exactly are you trying to do here?
guetch();
I suspect you meant
getch();
. How did this program even compile?