#include <stdio.h>

int main()
{
    char opt;

    do
    {
         printf ("Enter y or n: ");
         opt = getchar();     
    }
    while (opt != 'y' || opt != 'n');   

}

okay so my code does not stop when I enter y or n, which I think it should.

replace the or with and (&&)

Omg thanks.

Remember to add "return 0" at the end of main function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.