Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Change a variable using debug mid running

+2 votes
asked Jan 28, 2022 by wasp000789 (140 points)
How do I make so while the code is running, it may for e.g. ask me in the debug to write a var "num" and it will change to what I typed in mid the code running?
Or for e.g. will ask something and I can choose either that will be "true" or "false"?
Thank you in advance

1 Answer

0 votes
answered Feb 6, 2022 by Peter Minarik (87,340 points)

What language are we talking about?

I pretty much doubt that you want to change the value of a variable while debugging (GDB), rather you would like to take input from the user. Is that right?

In C, basic user input would look something like this.

#include <stdio.h>

int main()
{
    char name[50];
    printf("What's your first name? ");
    scanf("%s", name);
    printf("Hello, %s!", name);
    return 0;
}

Check printf() out for more details.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...