mardi 5 mai 2020

C++ Segmentation Fault while using online Compiler but the Same works in VS Code

I am new to C++ Programming. I'm getting Segmentation Fault error while compiling my code in online compilers but when I try compile it using Visual Studio Code and g++ in offline(means in my local machine) works fine.

The Code I have tried is

`

#include <iostream>

int main() {
    int *ptr;
    *ptr = 10;
    cout<<*ptr; //Prints 10 
    cout<<ptr; //Prints Some garbage address
}

But the above program not working in online compilers(used onlinegdb). My machine configuration g++ 11 Visual Studio Code 2016

Aucun commentaire:

Enregistrer un commentaire