I yanked this code from Beej's Guide to Network Programming:
struct sockaddr_in antelope;
char *some_addr;
inet_aton("10.0.0.1", &antelope.sin_addr); // store IP in antelope
some_addr = inet_ntoa(antelope.sin_addr); // return the IP
printf("%s\n", some_addr); // prints "10.0.0.1"
// and this call is the same as the inet_aton() call, above:
antelope.sin_addr.s_addr = inet_addr("10.0.0.1");
What we have here is an example of moving an ip address back and forth between the type of struct which is generally used for storing address info and a string. The last line of this code is basically what you need. The integer representation of the ip address is being stored in antelope.sin_addr.s_addr. s_addr is just an unsigned long, so it should be exactly what you need. If you were to do this:
cout << antelope.sin_addr.s_addr << endl;
you would get the decimal representation of 10.0.0.1
EDIT: I added a comment under your original code to express the issue with the code that you already had, which is basically just an issue with endianness. The code I gave you in this answer might give you the same problem. You need to use htonl() to reverse the byte order.