-1

I wanted to print garbage value with an uninitialized variable. But when I tried to build the code on visual studio, it gives me a window and on the window there isn't option to ignore and execute. How can I execute this code?

#include <stdio.h>

void scopes();
void localvar();
int main(void) {
    
  localvar();

  return 0;
}

void localvar() {
  int m;
  int n = 10;

  printf("%d %d\n", m, n);

  for (m = 0; m < 3; m++) {
    auto int sum = 0;
    sum = m;
    printf("%d %d\n", m, sum);
  }
  return;
}
Rachid K.
  • 4,490
  • 3
  • 11
  • 30
송효근
  • 47
  • 5

1 Answers1

3

For Visual Studio it's an error to have uninitialized variables, so your program simply doesn't compile.

You can tell the compiler to ignore these errors by putting this at the beginning of your code:

#pragma warning (disable: 4700)
Jabberwocky
  • 48,281
  • 17
  • 65
  • 115