Hello, I am trying to learn to use MinGW, as I am going through a set of tutorials. I have a piece of old code that I done from a book that works on visual studio, but when I try to run it with MinGW I am getting 2 errors that I do not understand, along with numerous warnings about null pointers, throughout the entirety of the code.
The errors I am getting are
1:3: error: expected unqualified-id before '/' token
1 | ■/ *
| ^
Which is the very first line of the code, I understand it obviously has something to do with the comment and the / use, but I cannot understand why, especially since it works on visual studio.
The second error is,
cpp: 27:2: error: 'i' does not name a type
27 | }
| ^
This is the very last line of the code, the very last } to close off the code.
Does anyone know what could be causing these problems, and if so why these errors are showing here but they would not be in visual studio?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
/*
Write a C++ Program to Add Two Numbers.
In this program, user is asked to enter two integers. Then, the sum of those two integers is stored in a variable and displayed on the screen.
*/
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int num1, num2, total;
cout << "Please enter a number for the first number" << endl;
cin >> num1;
cout << "Please enter a number for the second number" << endl;
cin >> num2;
cout << "The total of these numbers is: " << num1 + num2 << endl;
system("pause");
return 0;
}
|