how do i get.line() for integers ?
sorry iam very new with c++ and with this website.
if my quastin is idiotic delete it.
tnx for helpers.
//code
include <iostream>
using namespace std;
void Div(int* num);
void Prime( int* num );
void Sum(int* num);
void main(){
int *num= new int[4]; //like 1000??
int a;
cout << "1" << endl;
cout << " 2" << endl;
cout << " 3" << endl;
cout << "To exit press 0" << endl;
cin >> a;
cin.ignore();
switch (a){
case 0:
cout << "Good bye" << endl;
exit(0);
break;
case 1:
cout << "Enter your number:" << endl;
cin >> num; // cin.getline()? but for int number if it was a char i would do like cin.getline(str,4)? right?
Div(num);
break;
case2:
cout << "Enter your Number" << endl;
Prime(num);
break;
case 3:
cout << "Enter your Number" << endl;
Sum(num);
break;
}
Next time, use code formatting([.code] tag, without the dot).
As for the question: please, read once again the chapter about integers, pointers and I/O. int* is a pointer to an integer, and you want to get integer. num should be an int, not int*. Moreover, int[4] is an array of 4 integers, instead of 4-wide integer.
Also, void main() isn't C++. You should use int main() (with optional arguments, if you want to use them). Main must return an int.