I have never seen anybody use this forum as a place to save and reference code or anything for that matter.. Interesting ;-;
You know forums aren't the best places to do such stuff (and some are more strict in enforcing proper use), try googling next time, there's a lot of website hosts for stuff exactly like this. Some are even specially designed for code! ;)
If this was to be referenced by another post in this forum, remember the character limit is 8000 characters.. and that's a lot. I'm sure you would have been able to fit it in that post itself. No need to split posts that just annoys readers.
But this is your first post so is it even for this forum..
And lastly if you're not going to reference this in some other forum post somewhere then god damn freaking use the damn notepad that comes on every computer! That even is remotely accessible.
@shamelessguy,
as Ganado pointed out, you’d better check if argc > … before accessing argv.
Also:
a) if(nombreFichero.find(".dat",nombreFichero.length() - 4) could crash the program if nombreFichero.length() < 4.
b) m = std::stoi(argv[3]); would throw an exception if argv[3] is not convertible into an integer (the same issue repeats few rows below).
c) if(nombreFichero.find("datos",0) == std::string::npos) whould consider names like abcdefghijklm_datos.dat as good names; is that the expected behaviour?
d) You could save time by taking advantage of the standard library features.