c++ - Segmentation Fault while comparing strings -


In my program, there is a part where I need to sort an array of structure, everything is fine until I It seems to be good till the end, everything is fine for some entries and works up to some entries at the end of the array. There it throws a division fault and why I do not know. struct overview_table {string o_timestamp; String n_timestamp; String dbid; }; Type (overview.begin (), overview.end (), compareStrings); Compare static hair strings (counter overview_table & amp; a_timestamp, const overview_table & amp; amp; amp; b_timestamp) {cout & lt; & Lt; "744" & lt; & Lt; Endl; If (a_timestamp.n_timestamp.compare (b_timestamp.n_timestamp) & lt; = 0) {cout & lt; & Lt; "746" & lt; & Lt; Endl; Back true; } And {cout & lt; & Lt; "74 9" & lt; & Lt; Endl; return false; }}

For information: The output was just to check whether departmental faults have been thrown. And it's between 744 and 746 and how do I think at the end of the array. But I do not know why

The comparison work will fulfill the principle of weak command.

Change the function to

  Compare Stable Bull Strings (Constant Overview & Tablet & amp; a_stemestamp, const overview_table & amp; b_timestamp) {return a_timestamp} N_timestamp & lt; B_timestamp.n_timestamp; }    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -