-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_char
70 lines (53 loc) · 1.28 KB
/
parse_char
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
#include <QCoreApplication>
#include <QDebug>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
char source[100];
char sign[] = "WIFI";
char ssid[] = "xxxxxx";
char sep[] = "|";
char pass[] = "yyyy";
strcpy(source, sign);
strcat(source, sep);
strcat(source, ssid);
strcat(source, sep);
strcat(source, pass);
strcat(source, sep);
qDebug() << source;
char nSsid[33];
char nPass[33];
char * pch;
pch = strstr (source,"WIFI");
int state = 0;
if ((pch - source+1) == 1)
{
int i = 0;
int idx = 0;
while (i < 100)
{
if (state == 1)
nSsid[idx] = source[i];
else if (state == 2)
nPass[idx] = source[i];
i++;
idx++;
if (source[i] == '|')
{
if (state == 1)
nSsid[idx] = '\0';
else if (state == 2)
nPass[idx] = '\0';
state++;
i++;
idx = 0;
if (state > 2)
break;
}
}
qDebug() << "nssid: " << nSsid << " nPass: " << nPass;
}
return a.exec();
}