Good evening to everyone, I try to debug this little program in visual studio code in ubuntu:
#include <string>
#include <iostream>
int main(int argc, char* argv[])
{
std::string folder = argv[1];
}
but the debug terminate with this error in the terminal:
"terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid "
and this in the debug console:
"Unable to open 'raise.c': Unable to read file (Error: File not found (/build/glibc-4WA41p/glibc-2.30/sysdeps/unix/sysv/linux/raise.c))."
So the question are:
1) Is possible to display the number of the line where the error occurs? (In this case line 6)
2) Why does this error happen, and how to avoid it?
3) For avoiding this problem I can write, for example:
string folder = "/home/lorenzo/Images";
but I don't want to do that. For "running" the program from the terminal I write ./main /home/lorenzo/Images, so I pass the folder to the program in this way. Is possible to do the same thing when debbuging, without writing the folder directly in the program, or using cin?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire