RemedyBG»Forums
Gaurav Gautam
98 posts
Is there a way to start debugging a program while using a file for stdin ( remedy version 0.3.8.4)?
Edited by Gaurav Gautam on

Hello,

I'm using remedy for some coding practice sites and these invariably require that I have to read inputs from a testcases file. Is there a way to start a program inside remedy such that it will take the stdin from a file? I tried putting < testcases.txt in the command field but then it can't run the executable.

I also tried putting it in the arguments like this. This works in visual studio.

image.png

Mārtiņš Možeiko
2559 posts / 2 projects
Is there a way to start debugging a program while using a file for stdin ( remedy version 0.3.8.4)?

Don't know about remedy, but you can always reopen stdin/out streams during debugging/development:

freopen("testcases.txt", "r", stdin);
13 posts
The classic game dev.
Is there a way to start debugging a program while using a file for stdin ( remedy version 0.3.8.4)?
Edited by Scr3amer on

Hello Sir !

If you have the source code of the app, you can modify your main to have a waitloop

int main()
{
    while(!IsDebuggerPresent()); // Loop without doing anything
    __debugbreak(); // Trigger a breakpoint once the debugger is attached and ready

    ... // Rest of the app
}

And run it from the terminal and then attach Remedy and it will automatically break on the __debugbreak();

Cheers

Reference:
https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-isdebuggerpresent
https://learn.microsoft.com/en-us/cpp/intrinsics/debugbreak?view=msvc-170

Gaurav Gautam
98 posts
Is there a way to start debugging a program while using a file for stdin ( remedy version 0.3.8.4)?
Edited by Gaurav Gautam on
Replying to mmozeiko (#29320)

ah thankyou! This solves other problems I was having too.

Gaurav Gautam
98 posts
Is there a way to start debugging a program while using a file for stdin ( remedy version 0.3.8.4)?
Replying to Scr3amer (#29321)

Thankyou! This should work for my purposes.