No output While storing the content of file by splitting using strtok function

Dear Friends,
When I try to print the content of file ( /proc/net/wireless) it is fine but I want only some part of file. so for that I used strtok function to split by individual token so that I can Store required one.

but it is not working please any could help me to get out of this problem.

program:

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
#include<iostream>
#include<fstream>
#include<string.h>
#include<stdio.h>
using namespace std;

int main() {
string line;
const char* ifname = "wlan0";
ifstream input ("/proc/net/wireless");

if(!input.is_open())
{
cout << "Couldn't open the file " << endl;
}

    while(getline(input, line)){
        char *bp = strdup(line.c_str());

while(*bp && isspace(*bp))
bp++;
//if(strncmp(bp,ifname,strlen(ifname))==0 && bp[strlen(ifname)]==':')
  //          {
bp = strchr(bp, ':');
bp++;

              bp = strtok(bp, " ");
             cout << bp ;
           
            bp = strtok(NULL, " ");
              if(strchr(bp,'.') != NULL)
                
		cout << bp ;           
              bp = strtok(NULL, " ");
              if(strchr(bp,'.') != NULL)
		cout << bp;              
              bp = strtok(NULL, " ");
              if(strchr(bp,'.') != NULL)
              
              cout << bp;
              bp = strtok(NULL, " ");
		cout << bp;
              bp = strtok(NULL, " ");
	           cout << bp;
              bp = strtok(NULL, " ");
		cout << bp;

        std::cout <<"End of line"<<std::endl;
//     delete bp;
   // }
    return 0;
}

}
 


output :

Blank output it is giving.

Best Regards
Babu
Topic archived. No new replies allowed.