ThatAid3n
ThatAid3n

Reputation: 69

Having problems debugging a C++ program

I am writing to say that I made a program in C++ that would convert Celsius to Fahrenheit (I know, its been done, and this was my first project in c++), and once I was finished, and was debugging, it said [ERROR] 'SYSTEM' was not declared in this scope once I typed in

SYSTEM ("PAUSE")
return 0;

}

, } was there before in the code. I searched up how to fix it, and went to the first 10 links in the google engine, and none of it worked. I could use some help, should I get a new IDE (compiler)? Or is it that I am just no good in C++?

My code was:

//
// Program to convert temperature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
    // enter the temperature in Celsius
    int celsius;
    cout << “Enter the temperature in Celsius:”;
    cin >> celsius;
    // calculate conversion factor for Celsius
    // to Fahrenheit
    int factor;
    factor = 212 - 32;
    // use conversion factor to convert Celsius
    // into Fahrenheit values
    int fahrenheit;
    fahrenheit = factor * celsius/100 + 32;
    // output the results (followed by a NewLine)
    cout << “Fahrenheit value is:”;
    cout << fahrenheit << endl;
    // wait until user is ready before terminating program
    // to allow the user to see the program results
    system(“PAUSE”);
    return 0;
}

Upvotes: 0

Views: 112

Answers (2)

IronEagle
IronEagle

Reputation: 550

@TNTFreaks - beat me to it.

Also, system calls are not secure, you might want to try using an alternate method (personally, I use cin.get(); cin.ignore();) You might try looking at: Alternative to system("PAUSE")? ---- system("pause"); - Why is it wrong? ---- System() calls in C++ and their roles in programming.

Upvotes: 2

PR06GR4MM3R
PR06GR4MM3R

Reputation: 397

You are using smart quotes instead of straight quotes which prevents your program from compiling, but other than that the program works fine.

Use " not or .

Upvotes: 3

Related Questions