mercredi 26 mai 2021

why sscanf is not handling or ignoring spaces in c++?

I have the following line to be put up in sscanf but its not accepting white spaces

         char store_string[25],store_string1[10];
          std::tm t={};
           int store_integer,store_integer1,store_integer2;
           int total_read;
       
       char* buff1 = "Demo to dispay (Appname,App usage) with date (03/11/2005) with test id (87773) data added (0) total ((null))";
       char* buff2 = "Demo to dispay %s with date (%d/%d/%d) with test id (%d) data added (%d) total ((%d))";
        
         total_read = sscanf(buff1, buff2 , store_string,  &t.tm_mon,
        &t.tm_mday,
        &t.tm_year,
        &store_integer,&store_integer1,&store_integer2);

   

output :

   if buff1 has display (Appname,Appusage) it works fine

  But If buff1 has display (Appname,App usage) it fails

Aucun commentaire:

Enregistrer un commentaire