Q:

why does my code stay in a loop when i run it

#include <iostream>
#include <string>
#include <ctime>

using namespace std;

class PVR {
private:
    int channel;
public:
    PVR() {
        cout << "Select the channel ==> ";
        cin >> channel;
        cout << endl;
    }
};

class DVR  {
private:
    string position;
public:
    DVR() {
        cout << "Select the position ==> ";
        cin >> position;
        cout << endl;
    }
};

class Oven {
private:
    string food;
public:
    Oven() {
        cout << "What do you want to bake? ==> ";
        cin >> food;
        cout << endl;
    }
};

class PrgDevice {
private:
    tm startTime;
    tm stopTime;
    int choice;
    int choice1;
    char c;
public:
    void dateTime() {
        cout << "Enter start date and start time: ";
        cin >> startTime.tm_mday >> startTime.tm_mon >> startTime.tm_year >> startTime.tm_hour >> startTime.tm_min >> startTime.tm_sec;
        cout << "Enter stop date and stop time: ";
        cin >> stopTime.tm_mday >> stopTime.tm_mon >> stopTime.tm_year >> stopTime.tm_hour >> stopTime.tm_min >> stopTime.tm_sec;
    }

    void mainMenu() {
        while (choice != 3) {
            cout << "Main menu options: \n";
            cout << "      1. Select a device to program (contains a submenu)" << endl;
            cout << "      2. Display current status of all devices" << endl;
            cout << "      3. Exit" << endl;
            cout << "Enter your option => ";
            cin >> choice;

            if (choice == 1) {
                subMenu();
            }
            else if (choice == 2) {
                cout << choice;
            }
            else {
            }
        }
    }
    void subMenu() {
        do {
            cout << "Select a device:" << endl;
            cout << "         1. PVR" << endl;
            cout << "         2. Camera DVR" << endl;
            cout << "         3. Oven" << endl;
            cout << "Enter your option => ";
            cin >> choice1;

            if (choice1 == 1) {
                PVR n1;
            }
            else if (choice1 == 2) {
                DVR n2;
            }
            else {
                Oven n3;
            }
            dateTime();
            cout << endl;
            cout << "Another device to program Y/N ? => ";

            cin >> c;
        }
        while(c == 'Y' || c == 'y');
    }
};

int main() {
    PrgDevice obj1;
    obj1.mainMenu();

    system("pause");
    return 0;
}

This is my output
Main menu options: 
      1. Select a device to program (contains a submenu)
      2. Display current status of all devices
      3. Exit
Enter your option => 1
Select a device:
         1. PVR
         2. Camera DVR
         3. Oven
Enter your option => 1
Select the channel ==> 23
Enter start date and start time: 12:01:19 20:00:00

when i press enter my program just goes in a loop and i dont know why it does

A:

The problem is that your programs wants the user to input the time and date as space-separated values, but you input them as colon-separated values.
That means
cin >> startTime.tm_mday >> startTime.tm_mon >> ...

will read the 12 into startTime.tm_mday, but then there is a : in the input which doesn't match the type of startTime.tm_mon. That will stop all reading of input, leaving the : in the input buffer for your next input operation.
The next input operation is for stopTime which will fail immediately because of the : in the input buffer. So then you're back in the subMenu function where the colon will be read into c. And ':' is not equal to 'Y' or 'y', so the loop ends, and the subMenu function returns back to mainMenu where you print the menu again.

A:

That doesn't feel like an infinite loop to me. Try entering the start time as:  
12 1 19  20 0 0

cin won't magically handle the ':' characters in your input, so you might need to read the entire line, and parse out the ':' chars. 

