I am trying to get fingerprint data (which I created and stored as a text file in another code) which I have to compare with a new fingerprint in this code. The problem is that the fingerprint API requires the fingerprint data to be passed as char pointer. I'm using the following code :
std::ifstream infile("timestamp.txt");
char* text_stream;
std::string line;
  if (infile.is_open()){
    while ( getline (infile,line)){
        if(text_stream){
            *text_stream = malloc (1 + strlen (line));
            strcpy(text_stream,line);
        }
        else{
            fprintf (stderr, "malloc failure!");
        }
    }
    infile.close();
  }
I have also tried using other codes for the same purpose but I'm getting this kind of compilation error everytime:
verifiy.cpp: In function ‘int main()’:
verifiy.cpp:29:47: error: cannot convert ‘std::string {aka std::basic_string<char>}’ to ‘const char*’ for argument ‘1’ to ‘size_t strlen(const char*)’
    *text_stream = malloc (1 + strlen (line));
                                           ^
verifiy.cpp:30:31: error: cannot convert ‘std::string {aka std::basic_string<char>}’ to ‘const char*’ for argument ‘2’ to ‘char* strcpy(char*, const char*)’
    strcpy(text_stream,line);
                           ^
 
     
     
    