资源简介
2016年5月8日cplusplus.com全站离线版压缩包,解压后200M左右,可无网、内网环境下访问查阅STL等
代码片段和文件信息
// Subnet Calculator by rocco castoro
#include “stdafx.h“
#include
#include
#include
#include
#include
#include
using namespace std;
int getOctetsIP(string ip vector &octetsIP) { // Define vector octets using reference from main
stringstream sip(ip); // use stringstream named ss and populate with ip
string temp;
octetsIP.clear(); // Clears the octetsMask vector in case main function re-runs this function
vector ipInRange;
while (getline(siptemp‘.‘)) // Every time getline recieves new stream element from ss save to temp
octetsIP.push_back(atoi(temp.c_str())); //... until reaches ‘.‘ delimiter then push_back octet with new element.
if (octetsIP.size() == 4) {
for(int i = 0; i < octetsIP.size(); i++){
if (octetsIP[i] >= 0 && octetsIP[i] <= 255)
ipInRange.push_back(true);
else
ipInRange.push_back(false);
}
if (ipInRange[0]==true&&ipInRange[1]==true&&ipInRange[2]==true&&ipInRange[3]==true){
return 0;
}else{
cout << endl << “There are only 255 bits per octet. Please re-enter IP.“ << endl << endl;
return 1;
}
}else{
cout << endl << “Please enter four octets in dot notation.“ << endl << endl;
return 1;
}
}
int getOctetsMask(string mask vector &octetsMask) {
stringstream smask(mask);
string temp;
octetsMask.clear(); // Clears the octetsMask vector in case main function re-runs this function
vector maskInRange;
while (getline(smasktemp‘.‘))
octetsMask.push_back(atoi(temp.c_str()));
if (octetsMask.size() == 4){
for(int i = 0; i < octetsMask.size(); i++){
if (octetsMask[i] == 0 || octetsMask[i] == 128 || octetsMask[i] == 192 || octetsMask[i] == 224 || octetsMask[i] == 240 || octetsMask[i] == 248 || octetsMask[i] == 252 || octetsMask[i] == 254 || octetsMask[i] == 255)
maskInRange.push_back(true);
else
maskInRange.push_back(false);
}
if(maskInRange[0]==true&&maskInRange[1]==true&&maskInRange[2]==true&&maskInRange[3]==true){
return 0;
}else{
cout << endl << “Subnet masks only use 2^[0-7]. Please re-enter mask.“ << endl << endl;
return 1;
}
}else{
cout << endl << “Please enter four octets in dot notation.“ << endl << endl;
return 1;
}
}
int calcClass(vector &octetsIP) {
if (octetsIP[0] == 10) {
return 1; // Class A Private address blocks //
}else if (octetsIP[0] == 172 && octetsIP[1] >= 16 && octetsIP[1] <= 31) {
return 2; // Class B Private address blocks //
}else if (octetsIP[0] == 192 && octetsIP[1] == 168) {
return 3; // Class C Private address blocks //
}else if (octetsIP[0] == 127) {
return 4; // Loopback Address Reserved address blocks //
}else if (octetsIP[0] >= 0 && octetsIP[0] < 127) {
return 5;
}else if (octetsIP[0] > 127 && octetsIP[0] < 192) {
return 6;
}else if (octetsIP[0] > 191 && octetsIP[0] < 224) {
return 7;
- 上一篇:point-04 多姿态人脸库
- 下一篇:pdftoword0406.rar
相关资源
- OpenCV By Example (OpenCV3)
- 数据结构实用教程(第2版).pdf 主编
- Exe守护程序
- 海康相机SDK+QT二次开发.rar
- QtitanRibbon 4.8代码
- cmake-3.16.2-win32-x86.msi
- BCGControlBar 英文说明文档 28版本
- C+Primer+Plus++第6版++中文版_PDF电子书
- OpenGL开发的教室场景可以漫游
- 后台开发核心技术与应用实践高清P
-
AutoCAD ob
jectARX(VC)开发基础与教程 - [免费PDF高清]2018年最新编程珠玑(第
- Linux多线程服务端编程 - 陈硕高清完整
- vs2010串口发送接收程序
- Boost程序库探秘.pdf
- OpenSceneGraphReferenceDocs-3.4.0.chm
- [免费]GB28181信令交互代码.rar
- 火狐NP插件开发
- vc运行库修复工具
- opencv4.0.1+contrib+vs2017编译x64x86完全版本
- 推箱子及其地图编辑器
- 精通Windows API-函数、接口、编程(源
- 获取屏幕上任意一点的RGB值
- 李建忠_设计模式源码和课件.rar
- UG585 - Zynq-7000 SoC Technical Reference Manu
- Linux窗口程序设计-Qt4精彩分析 part02
- 蓝桥杯历年试题附完整测试数据和题
- 双目标定后的三维重建
- 泛型编程与STL中文版 -----侯捷
- Make: Getting Started with Arduino 3rd
评论
共有 条评论