| | |
Store Bluetooth remote address to a text file
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2004
Posts: 6
Reputation:
Solved Threads: 0
Hi there!
Using the code below I am able to discover the bluetooth address of a remote host and print it on the screen.
However, I would like to 'get' this bluetooth address, before printing on the screen, and store it in a text file on my PC.
How am I supposed to do that?
Thanks a lot.
The code to scan for other bluetooth devices:
SOCKADDR_BTH *pAddrBthLocal=(SOCKADDR_BTH*)pCSAddrDevices->LocalAddr.lpSockaddr; AddrBthLocal.btAddr=pAddrBthLocal->btAddr
The code to print the remote bluetooth device's address on the screen:
addressSize = sizeof(addressAsString);
if (0 == WSAAddressToString(pCSAddrDevices->RemoteAddr.lpSockaddr, pCSAddrDevices->RemoteAddr.iSockaddrLength,
&protocolInfo, addressAsString, &addressSize)){
UpdateData(true);
Aux.Format("Remote Address: %s\n", addressAsString);
m_SocketInfo.operator +=(Aux);
UpdateData(false);
Using the code below I am able to discover the bluetooth address of a remote host and print it on the screen.
However, I would like to 'get' this bluetooth address, before printing on the screen, and store it in a text file on my PC.
How am I supposed to do that?
Thanks a lot.
The code to scan for other bluetooth devices:
SOCKADDR_BTH *pAddrBthLocal=(SOCKADDR_BTH*)pCSAddrDevices->LocalAddr.lpSockaddr; AddrBthLocal.btAddr=pAddrBthLocal->btAddr
The code to print the remote bluetooth device's address on the screen:
addressSize = sizeof(addressAsString);
if (0 == WSAAddressToString(pCSAddrDevices->RemoteAddr.lpSockaddr, pCSAddrDevices->RemoteAddr.iSockaddrLength,
&protocolInfo, addressAsString, &addressSize)){
UpdateData(true);
Aux.Format("Remote Address: %s\n", addressAsString);
m_SocketInfo.operator +=(Aux);
UpdateData(false);
•
•
Join Date: Jun 2004
Posts: 6
Reputation:
Solved Threads: 0
thanks and sorry for late replying but i was away for a week.
ok i changed the code in the following way but I get the errors below.
Code:
}
addressSize = sizeof(addressAsString);
if (0 == WSAAddressToString(pCSAddrDevices->RemoteAddr.lpSockaddr, pCSAddrDevices->RemoteAddr.iSockaddrLength,
&protocolInfo, addressAsString, &addressSize)){
UpdateData(true);
Aux.Format("Remote Address: %s\n", addressAsString);
ofstream foo("foo");
foo << addressAsString;
foo.close();
m_SocketInfo.operator +=(Aux);
UpdateData(false);
}
The errors:
error C2065: 'ofstream' : undeclared identifier
syntax error : missing ';' before identifier 'foo'
'foo' : undeclared identifier
<<' : illegal, right operand has type 'char [1000]'
left of '.close' must have class/struct/union type
Am I missing something?
ok i changed the code in the following way but I get the errors below.
Code:
}
addressSize = sizeof(addressAsString);
if (0 == WSAAddressToString(pCSAddrDevices->RemoteAddr.lpSockaddr, pCSAddrDevices->RemoteAddr.iSockaddrLength,
&protocolInfo, addressAsString, &addressSize)){
UpdateData(true);
Aux.Format("Remote Address: %s\n", addressAsString);
ofstream foo("foo");
foo << addressAsString;
foo.close();
m_SocketInfo.operator +=(Aux);
UpdateData(false);
}
The errors:
error C2065: 'ofstream' : undeclared identifier
syntax error : missing ';' before identifier 'foo'
'foo' : undeclared identifier
<<' : illegal, right operand has type 'char [1000]'
left of '.close' must have class/struct/union type
Am I missing something?
•
•
•
•
Originally Posted by labamba
Am I missing something?
Did you try including fstream.h#include <fstream.h>
ok, then try using it like this.
C++ Syntax (Toggle Plain Text)
#include <fstream.h> void main() { ofstream file; //your code file.open("log.txt",ios::app); file<<"what erver you want :-)"; file.close(); }
Good you fixed it.Now get going onto proper file i/o and log the stuff you need in an organised fasion.
•
•
Join Date: Jun 2004
Posts: 6
Reputation:
Solved Threads: 0
Problem continuing...:
Hi there.
Now that i have the MAC address in a text file I was just wondering how I can 'graphically' show the stats of this text file (ie. that the mac address 0A:4h:3e:1b has been recorded 3 times at that time of the day etc.)?
I would really appreciate it if you could help me on this matter.
Thanks a lot
PS Should I change the format of the file (instead of .txt to use a .xml maybe?)
Hi there.
Now that i have the MAC address in a text file I was just wondering how I can 'graphically' show the stats of this text file (ie. that the mac address 0A:4h:3e:1b has been recorded 3 times at that time of the day etc.)?
I would really appreciate it if you could help me on this matter.
Thanks a lot
PS Should I change the format of the file (instead of .txt to use a .xml maybe?)
![]() |
Similar Threads
- Help with delphi project (Pascal and Delphi)
Other Threads in the C++ Forum
- Previous Thread: retreiving the maxnum & minnum
- Next Thread: Need help with including C++ code in Word macro
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





