0

Possible Duplicates:
C++ Read Lines from File
File based Configuration handling in C ( Unix )

Using C++ how can I extract data for int id; string name; char mac[6]; from a configuration file: config.txt. Contents of which are for example:

ID 34
Name BUZINGA
MAC 0x67:0x45:0x4d:0x5d:0xcc:0x13
Community
  • 1
  • 1
Uthman
  • 9,251
  • 18
  • 74
  • 104

1 Answers1

1

First, search the web and Stack Overflow for the keywords "parsing" and "file". To narrow your search, add the keywords "mac address c++".

Next, prefer to read data into memory than process memory. In other words, read a line of text into a string and use methods of std::string for finding items in the text.

Research std::stringstream for ways to convert textual representations of numbers to their internal representations.

Try something on your own. If you have issues, post the smallest amount of code to recreate the issue along with the compiler output as well as what you expect the program to produce.

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154