CodeBlocks questions

Perhaps this is a question for a forum on CodeBlocks, but I don’t exactly know what to write since I’m so new to C and the IDE so…I was writing code on >CodeBlocks and running it successfully in the terminal. Recently, when i run the same code on CodeBlocks the terminal appears but nothing appears in it. it’s completely blank. What might be the issue?

Screenshots might be helpful in diagnosing what’s wrong. And information regarding the code you’re running might help.

1 Like

Of course.
Here is my code:

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

int main()
{
    int num1;
    scanf("%d", &num1);

    int num2;
    scanf("%d", &num2);

    printf(num1+num2);

    return 0;
}

When I Run/Build my code, I get the following from the command line:

This code worked fine two days ago. What might have changed so that the command line doesn’t run my code?
Or, what would cause the command line to do something like this?

That code is somewhat performing exactly what it is intended to do. It’s waiting for input.
Type a number, hit enter. Then type a number and hit enter again. Then everything will be running.

Edit: At line 14, the compiler will attempt to read any raw number as an pointer. Meaning it will crash before it will print a number out. Use a format string to print numbers to the console like so.

printf("%d",num1 + num2);
2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.