0

I'm attempting to parse data from a exported text file from a database. I want to extract the data from the string and run a algorithm on it. I first tried using sscanf since that is what I'm familiar with, even though it probably isn't the best choice. Any help would be very much appreciated. I was getting very confused with some of the information I found online, for example the Boost Library. Here is just one row of data I'm attempting to parse. Ask any questions you need to, thanks.

1;3;8;"Fitted 1MX Stretch Cotton Shirt";"Berry";59.9;"http://www.express.com/clothing/men/fitted-1mx-stretch-cotton-shirt/pro/0303885/cat1390003"

Here is the order of the data, with data types (if important) and the semicolon is a delimiter.

int;int;int;string;string;double;string
user3268054
  • 111
  • 1
  • 3
  • 11

1 Answers1

0

All you need to do is to split your string. Here's an example.

Then, having a vector with fixed size (compare its length it to validate your string) you only need to get ints or doubles with std functions:

  • stod
  • stoi
  • stof

Defined in <string> header.

Community
  • 1
  • 1
Croll
  • 3,631
  • 6
  • 30
  • 63