Big Rat

Oct 25, 2018 at 4:53pm
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.

I have no clue why I wrote so much for this.. ;p
Oct 25, 2018 at 6:31pm
 
	std::string nombreFichero = argv[1]; //string que es el nombre del fichero introducido 

Si argc == 1, el programa fallará.
Last edited on Oct 25, 2018 at 6:32pm
Oct 25, 2018 at 7:43pm
It's the random comment thread.
Oct 25, 2018 at 11:21pm
@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.

Happy coding!
Topic archived. No new replies allowed.