-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpingfunctions.cpp
More file actions
73 lines (60 loc) · 1.31 KB
/
Copy pathpingfunctions.cpp
File metadata and controls
73 lines (60 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "pingfunctions.h";
int WordsInString(string str)
{
int counter = 0;
string temp= " ";
while (temp != "")
{
counter++;
temp = ExtractWord(str, counter);
}
counter--;
return counter;
}
string ExtractWord(string str, int counter)
{
stringstream ss;
string temp, exwords;
ss << str;
while (!ss.eof() && counter > 0)
{
/* extracting word by word from stream */
ss >> temp;
counter--;
if (counter == 0)
{
exwords = temp;
}
temp = "";
}
return exwords;
}
int YesOrNo(string ch)
{
int temp;
if (ch == "N" || ch == "n" || ch == "no" || ch == "NO")temp = 0;
else if (ch == "Y" || ch == "y" || ch == "yes" || ch == "YES")temp = 1;
else temp = 2;
return temp;
}
int ExtractInt(string str, int counter)
{
stringstream ss;
string temp;
int found, num = 0;
ss << str;
while (!ss.eof() && counter > 0)
{
/* extracting word by word from stream */
ss >> temp;
/* Checking the given word is integer or not */
if (stringstream(temp) >> found)
{
num = found;
counter--;
}
/* To save from space at the end of string */
temp = "";
}
return num;
}