I am now using Visual studio code and I want to debug C/C++ program which runs as a command line. However, debug of Visual studio code just supports the normal program (not a command line program). When I want to debug a command line program, I need to edit my code in which I initialize the argument before running debugger. For example
int main(int argv, char *argc[])
{
if (argv != 2)
{
printf("Wrong syntax\nCorrect Syntax: readfile <source file>\n");
exit(1);
}
FILE *fp = fopen(argc[1], "rb");
}
When I want to debug, I need to initialize like this:
int main()
{
/*if (argv != 2)
{
printf("Wrong syntax\nCorrect Syntax: readfile <source file>\n");
exit(1);
}*/ //eliminate this part
argc[1] = "phonebook.dat";
FILE *fp = fopen(argc[1], "rb");
I find it annoying. So how do I change the debugger on VS code to debug C and C++ command line programs?