lundi 30 décembre 2019

How to split a string based on a char

I can get a substring from the following line

 string filename = C:\Shaders\Test\Model\source\scene.fbx"
 filename.substr( 0 , filename.find_last_of('\') );

this would be the result

  C:\Shaders\Test\Model\source

Now if i want to get the sub string from the last "\" to the end of the string that would be

   scene.fbx 

i am trying this line.

 filename.substr(filename.find_last_of('\'), filename.size() )

but i get a crash.

Aucun commentaire:

Enregistrer un commentaire