fork download
  1. #include <iostream>
  2. #include <cstdint>
  3. #include <strstream>
  4. #include <sys/socket.h>
  5. #include <netinet/in.h>
  6. #include <arpa/inet.h>
  7.  
  8. int main()
  9. {
  10. const std::string prefix = "192.168.52." ;
  11.  
  12. // loop through ips 192.168.52.0 to 192.168.52.15
  13. for( int i = 0 ; i < 16 ; ++i )
  14. {
  15. char buffer[1024] ;
  16. {
  17. std::ostrstream stm( buffer, sizeof(buffer) ) ;
  18. stm << prefix << i << std::ends ;
  19. }
  20.  
  21. in_addr_t addr = inet_addr(buffer) ;
  22. std::cout << addr << '\n' ;
  23. }
  24. }
  25.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
3451072
20228288
37005504
53782720
70559936
87337152
104114368
120891584
137668800
154446016
171223232
188000448
204777664
221554880
238332096
255109312