Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22009

can you guys help me to debug a simple c program with gcc and make it work? (student problems..)

$
0
0

Hello guys so my question is can you help me to debug a simple c program with gcc and make it work?

The teacher gave me this code and I should debug it and make it work, i tried but without any help I can't do It.

I compiled it with g++ -g double_free.c -o double_free

The program crashes.

this is the code:

#include <stdlib.h>#include <stdio.h>#define ARRAY_SIZE 100000int main(int argc, char* argv[]){        int i, test=5;        int* buf = new int[100000];        for (i=0; i< ARRAY_SIZE; i++){               buf[i] = i;       }       int result = 0;       delete []buf;       printf("result: %d\n", result);       delete[] buf;       printf("test %d\n", test);       return 0;}

enter image description here


Viewing all articles
Browse latest Browse all 22009

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>