Search code examples
c++cincoutidentifier

CIN, COUT Undelcared Identifier


So I perused some of the other articles, but I can't seem to find a reason to why this won't work. I am new to C++ so be kind please.

// User Pay.cpp : Defines the entry point for the console  application.
// This program calculates the user's pay.

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
    double hours, rate, pay;

    // Get the number of hours worked.
    cout << "how many hours did you work? ";
    cin >> hours;

    // Get the hourly pay rate.
    cout << "How much do you get paid per hour? ";
    cin >> rate;

    //C alculates the Pay.
    pay = hours * rate;

    // Display the pay.
    cout << "You have earned $" << pay << endl;

    return 0;
}

Solution

  • Try creating an empty project (uncheck precompiled headers). then copy your code but delete #include "stdafx.h".