How to make a funcion in C++ which read from a file to an array of hex? -


first of must i'm total noob in c++ programing. have make funcion:

void license(bool& exists, unsigned int longlicense, unsigned int license[])

it has read txt file contains 6 hex numbers separated "-", example:

462e3784-11f24312-13b57611-27a3197f-3b30158a-ab7ef8e0

and save numbers (in decimal) in "license" array. has return true or false in "exists".

i've tried doing doesn't work. reads correctly first number. rest of them aren't same have in txt file.

#include <iostream> #include <fstream> #include <string>  #define n_int_license 6  using namespace std;  bool existe; unsigned int licencia[n_int_license];  ifstream stream; stream.open("license.txt"); if (stream) {     (int = 0; < n_int_license; i++) {         stream >> hex >> licencia[i];     } 

i didn't find other topic me if there 1 i'm sorry posting that. please me. thank you.

you should skip dash:

for (int = 0; < n_int_license; i++) {     stream >> hex >> licencia[i];     if (i!= n_int_license-1) {         char c;          stream >> c;          if (c!='-')             cout<<"error: invalid format";     } } 

by way, shall happen if license key short ?


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

java - Could not locate OpenAL library -

Non Unique Username with ASP.Net Identity 2.0 -