I want to know how i can use cin command to input a ip in a variable, i tried it a few time but didn't manage to do it, i made a little research and didn't found much, i found that i need o make the ip in a array but i don't know how to do it, i want it to be in a array bi only entering the whole ip in one cin if that's possible.
Thank you
1 2 3 4 5 6 7 8 9
#include <iostream>
usingnamespace std;
int main() {
int ip;
cout << "IP adress: ";
cin >> ip;
return 0;
}
I suggest you start by getting the address as a string then validating and converting this string to an actual value. And you probably shouldn't be using a single int to try to hold this value.