Whoops you have an infinite loop here

//This creates a LCV for the do loop below and sets it equal to 0.

int y = 0;

//This do loop generates the random number.
do
{
    //This generates a random time seed.
    srand(time(0));

    //This generates a random number between 1 and 99.
    ran = rand() % 100;

    //This while controls the do loop.
}while (y != 9);

y is initialized to 0 and you are looping while y!=9. And that is just the first error, there might be more.


Bug #2

int z = 1;
//This makes the program only create a random number the first pass through the loop.
if (z < 2)
{
    //This runs the random number generator function.
    return randomgen();

    //This sets the result of the function as the random number.
    randnum = randomgen();

    //This sets the random number to the current number.
    num = randnum;
}

After fixing infinite loop in randomgen(), You are immediately returning...

Answer from Tony Tannous on Stack Overflow
🌐
OnlineGDB
onlinegdb.com
GDB online Debugger | Compiler - Code, Compile, Run, Debug online C, C++
Online GDB is online compiler and debugger for C/C++. You can compile, run and debug code with gdb online. Using gcc/g++ as compiler and gdb as debugger. Currently C and C++ languages are supported.
Online C
OnlineGDB is online IDE with c compiler. Quick and easy way to compile c program online. It supports gcc compiler for c.
Online C++
OnlineGDB is online IDE with C++ compiler. Quick and easy way to compiler c++ program online. It supports g++ compiler for c++.
Java
OnlineGDB is online IDE with java compiler. Quick and easy way to run java program online.
Python
OnlineGDB is online IDE with python compiler. Quick and easy way to compile python program online. It supports python3.
🌐
Compiler Explorer
godbolt.org
Compiler Explorer
Compiler Explorer is an interactive online compiler which shows the assembly output of compiled C++, Rust, Go (and many more) code.
Top answer
1 of 2
3

Whoops you have an infinite loop here

//This creates a LCV for the do loop below and sets it equal to 0.

int y = 0;

//This do loop generates the random number.
do
{
    //This generates a random time seed.
    srand(time(0));

    //This generates a random number between 1 and 99.
    ran = rand() % 100;

    //This while controls the do loop.
}while (y != 9);

y is initialized to 0 and you are looping while y!=9. And that is just the first error, there might be more.


Bug #2

int z = 1;
//This makes the program only create a random number the first pass through the loop.
if (z < 2)
{
    //This runs the random number generator function.
    return randomgen();

    //This sets the result of the function as the random number.
    randnum = randomgen();

    //This sets the random number to the current number.
    num = randnum;
}

After fixing infinite loop in randomgen(), You are immediately returning...

2 of 2
1

you have two problems in your code: the first one is that you have infinite loop in randomgen() function the condition in check against y - y != 9 but the value never update

int randomgen() 
{
    //This creates a variable to store the random number.
    int ran;

    //This creates a LCV for the do loop below and sets it equal to 0.
    int y = 0;

    //This do loop generates the random number.
    do
    {
        //This generates a random time seed.
        srand(time(0));

        //This generates a random number between 1 and 99.
        ran = rand() % 100;

        //This while controls the do loop.
    }while (y != 9);

    //This returns the random number for use in the rest of the program.
    return ran;
}

and the second one is even if you pass the loop in the function you exit main right away because the call to the function randomgen() is with return

if (z < 2)
{
    //This runs the random number generator function.
    return randomgen(); <-- **second problome**

    //This sets the result of the function as the random number.
    randnum = randomgen();

    //This sets the random number to the current number.
    num = randnum;
}
🌐
LogicMojo
logicmojo.com › online-gdb-compiler
Online GDB Compiler By Logicmojo
It is an online compiler and debugger for common programming languages such as C, C++, Python, Java, PHP, Ruby, Perl, and others.
🌐
Reddit
reddit.com › r/django › how to create python ide similar to gdb online python
r/django on Reddit: How to create python IDE similar to gdb online python
March 15, 2024 -

I want to create a Python IDE using Django and JavaScript. I am facing an issue with taking user input when using the exec or eval functions in Python.

After further research, I came across subprocess and IPython, which seem like they could be used to create what I want, but I am still not very confident. Could you please suggest how to create a Python IDE using these tools or any other?

code = "print('Hello, my name is')\nk = input('Enter your name')\nprint(k)"
exec(code)

when i run the above code in the vs code by terminal then its

Hello, my name is
Enter your name

but when i run in Django then i didn't get

how to achieve same with Django?
code data will come from frontend.

Find elsewhere
🌐
YouTube
youtube.com › the code club
How to use online gdb debugger - C Programming. - YouTube
Learn how to use the online gdb debugger for C programming in this tutorial. Discover the benefits of using an online compiler for C programming and how to d...
Published   March 30, 2024
🌐
GNU Project
sourceware.org › gdb › documentation
GDB Documentation
December 22, 2023 - The GNU Press has printed versions of most manuals, including Debugging with GDB available. Documentation generated from the current sources are available online:
🌐
Reddit
reddit.com › r/learnpython › got a fork error on gdb online python compiler from a simple program
r/learnpython on Reddit: Got a fork error on gdb online python compiler from a simple program
March 27, 2024 -

The program was something like this:

class Pet:

def say(self):

print("Generic pet sound!")

class Dog(Pet):

def say(self):

print("Bark!")

D = Dog()

D.say()

super(Dog, D).say()

It was correct and started working when I reran it. I'm curious what might caused the compiler to give a fork error! Pls let me know if you guys know why it give the error! Thanks!

🌐
Reddit
reddit.com › r/c_programming › online gdb doesn't work as expected?
r/C_Programming on Reddit: Online GDB doesn't work as expected?
December 2, 2021 -

I am posting this both on r/Assembly_Language and here. I think the topic involves both fairly strongly.

So, I am going to do a presentation involving buffer overflows and I learned some basic Assembly because of that (more specifically the function prologue). I plan on learning Assembly for real and have installed SASM, but for now I just know basic C. I need help reading something.

In one of my sources (https://www.tenouk.com/Bufferoverflowc/Bufferoverflow4.html), this guy does disass in his vulnerable function in order to show that sub has allocated more space than he declared (4 vs 20).

This is his code:

#include <unistd.h>

 

void Test()

{

   char buff[4];

   printf("Some input: ");

   gets(buff);

   puts(buff);

}

 

int main(int argc, char *argv[ ])

{

   Test();

   return 0;

}

And this is the output of disass Test:

0x080483d0 <Test+0>:    push   %ebp

0x080483d1 <Test+1>:    mov    %esp, %ebp

0x080483d3 <Test+3>:    sub    $0x8, %esp

0x080483d6 <Test+6>:    sub    $0xc, %esp

Buff is 4 bytes and 20 bytes are "freed" on the stack. But when I try to do the same with a relatively more complicated function (I hope commentary is enough for the language gap):

#include <stdio.h>
#include <string.h>
#include <locale.h>     
#include <stdlib.h>        

void senha(){      
 char senha[10];           
    char senhareal[10]="dddddd";      
    int teste = 0;    
    char resposta[3]; 
    
    printf("\n\n\n\n-----------------------------SISTEMA NUCLEAR DA OTAN------------------------------------ \n\n\n\n");     
    
    
    printf("DIGITE SUA SENHA: ");
    gets(senha);


    if(0 == strncmp(senha, senhareal, 20))
    {
         printf ("\nSenha correta! \n");
         teste = 1;    
    }
    
    
    else
    {
        printf ("\nSENHA INCORRETA! \n");
    }


    if(teste)
    {
        printf ("\nO usuário agora controla a instalação! Deseja destruir o Brasil? \n");     
        gets(resposta); 
    }
            }

int main(){               
    system("color 03");
	setlocale(LC_ALL, "Portuguese"); 
    senha();  

    return 0;
}

I get this:

0x0000555555555209 <+0>: endbr64
0x000055555555520d <+4>: push %rbp
0x000055555555520e <+5>: mov %rsp,%rbp
0x0000555555555211 <+8>: sub $0x30,%rsp
0x0000555555555215 <+12>: mov %fs:0x28,%rax
0x000055555555521e <+21>: mov %rax,-0x8(%rbp)

No matter my input. So why does Online GDB consistently subtract 48 bytes? What are the instructions following sub and do they apply at all to what I am trying to do? Is it possible to know what's going on in that specific platform? Finally, am I unable to replicate what this person did with my code?

I tested the code of my source in Online GDB as well. It consistently subtracts 16 bytes.

🌐
WebCatalog
webcatalog.io › home › apps › software development › onlinegdb › desktop app
OnlineGDB - Desktop App for Mac, Windows (PC)
OnlineGDB is a comprehensive online integrated development environment (IDE) designed for coding, compiling, and debugging various programming languages. It supports multiple C++ standards, providing users with a robust platform for source code editing, compilation, execution, and debugging.
🌐
YouTube
youtube.com › tech world
Online GDB Tutorial C++: Free compiler and debugger - YouTube
Online GDB is a free and online compiler and debugger and this tech tutorial is gonna walk you through exactly how to use it. Here are the music credits ––––...
Published   August 29, 2019
Views   6K
🌐
YouTube
youtube.com › @Onlinegdb
Online GDB Debugger - YouTube
www.onlinegdb.com : An online compiler and debugger Lets you code, compile, run and debug online at ease. Supported programming languages: C, C++ Debugger: gdb, GNU debugger
🌐
Go
go.dev › play
Go Playground - The Go Programming Language
Common problems companies solve with Go · Stories about how and why companies use Go
🌐
Northern Illinois University
faculty.cs.niu.edu › ~byrnes › csci240 › onlinegdb.htm
CSCI 240 - Using the online GDB compiler and debugger for C/C++
There are many online C++ compilers for those that can't install a compiler on the device that is being used for the course. The new recommendation for CSCI 240 students is the compiler available at onlinegdb.com · https://www.onlinegdb.com/
🌐
YouTube
youtube.com › watch
Online GDB Free Compiler || How to use OnlineGDB
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
Landing.Jobs
landing.jobs › home › an intermediate guide to debugging c code with online gdb c compilers
An intermediate guide to debugging C code with online GDB C compilers - Landing.Jobs
February 16, 2023 - Online GDB is a popular online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, and JS. It allows you to code, compile, run, and debug online from anywhere, with any device.
🌐
Exercism
forum.exercism.org › t › the-code-compiles-properly-with-online-gdb-compiler-but-here-it-gives-an-error-of-segmentation-fault › 6802
The code compiles properly with online gdb compiler but here it gives an error of segmentation fault - Exercism - Exercism
August 7, 2023 - I developed a code for the exercise of isogram. The codes compiles perfectly with online gdb compiler but here it creates an error of segmentation fault, I don’t understand why. I am attaching my code below for reference…
🌐
W3Schools
w3schools.com › python › pandas › pandas_compiler.asp
Pandas Online Compiler (Editor / Interpreter)
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.