Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Output
- 192.168.2.2|
- -------
- ===================================================================
- file to read:
- Cycle : 7
- Server : 192.168.2.2|
- Mac : B8:27:EB:BF:08:BB
- =======================================================================
- Code:
- #include "Read.h"
- char temp[30];
- r.readAED(temp);
- std::cout << temp << "-----------" std::endl;
- server = gethostbyname(temp);
- void Read::readServer(char* type){
- FILE *f = fopen("/etc/device", "r");
- if (!f) {
- //Send Serial to Server.
- //return "e";
- }
- char line[256];
- char serial_string[30];
- while (fgets(line, 50, f)) {
- if (strncmp(line, "Server", 6) == 0) {
- atoi(strcpy(serial_string, strchr(line, ':') + 2));
- for (int i = 0; i < 30; ++i) {
- if (serial_string != " ")
- type[i] = serial_string[i];
- else
- type[i] = '_';
- }
- fclose(f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement