So I'm trying to create a C++ program that reads in a list of numbers(where the user enters a list of 5 numbers separated by spaces) and prints out the reversed list. so far, this is what I have:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#pragma warning(disable: 4996)
using namespace std;
int* get_Number() {
int* p = new int[32];
cout << "Please enter a list of 5 numbers, separated by spaces" << endl;
cin >> p;
return p;
};
int* reverseArray(int* numArray)
{
}
My problem is that I keep on getting this error:
Error: no operator ">>" matches these operands. Operand types are: std::istream >> int *
at the cin >> p
line.
What am I doing wrong? I'm new to C++, and any help would be greatly appreciated, thank you!!
How about this?
#include <iostream>
int main(int argc, char* argv[])
{
int nums[5];
std::cout << "Please enter a list of 5 numbers, separated by spaces" << std::endl;
for (int i = 0; i < 5; ++i)
std::cin >> nums[i];
for (int i = 0; i < 5; ++i)
std::cout << nums[i];
return 0;
}