Data Types - Ip - what holds it?

Hey guys so I am wanting people to be able to input an Ip. Though I can't seem to get a data type to hold an Ip. I want to be able to do something like this.

#include <iostream>
using namespace std;
#define NL '\n';

(something) ipadress;
int main()
{
cout << "Please enter the ip";
cout << NL;
cin >>ipadress;
cout << NL;
cout << "Your ip adress you entered is " << ipadress;
cout << NL;

return 0;
}

So I have tried using Int and char but they don't work :(. I also tried using string though it turns out they cant have input to them from a cin. Well atleast I can't figure it out :D.
Anyway it would be really nice if you guys could help me out.
Cheers
KingPulse
you need to #include <string> in order to use it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <string>
using namespace std;
#define NL '\n';

string ipadress;
int main()
{
cout << "Please enter the ip";
cout << NL;
cin >>ipadress;
cout << NL;
cout << "Your ip adress you entered is " << ipadress;
cout << NL;

return 0;
}


Please use code tags: [code]Your code[/code]
See: http://www.cplusplus.com/articles/z13hAqkS/
Topic archived. No new replies allowed.