0

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;
}
halfer
  • 19,824
  • 17
  • 99
  • 186
ThatAid3n
  • 71
  • 2
  • 7
  • [Maybe the error is because System() receives a pointer as a parameter rather than a string](http://www.cplusplus.com/reference/cstdlib/system/) – Janilson May 05 '18 at 02:34
  • How does you compile your code containing such quotes? The first error I get: *prog.cpp:14:13: error: stray ‘\342’ in program*. When you edit correctly your code I suggest you `#include ` – 273K May 05 '18 at 02:36

2 Answers2

3

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 .

PR06GR4MM3R
  • 397
  • 2
  • 13
  • Thank you! The program ended up with no bugs, and the system("pause") ended up working; and the program compiled! – ThatAid3n May 06 '18 at 17:02
  • No problem! Happy coding! To accept an answer push the check mark under the votes. This helps other users locate answered questions for problems that they may have. – PR06GR4MM3R May 06 '18 at 18:23
  • @ThatAid3n forgot to tag you in the last one oops – PR06GR4MM3R May 06 '18 at 18:23
  • @ThatAid3n Don't forget to mark this answer as accepted! It will make it easier for others who read this to find the right answer, and it will reward TNTFreaks with reputation for taking the time to help you. :) – NetherGranite Aug 05 '18 at 13:29
2

@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.

IronEagle
  • 550
  • 7
  • 17