run time and pc freezes

I just finished writing a short code..been sitting on it since 5 hours ago getting me all sweaty in the heat...and come run time what happens? my whole pc freezes up and i have to force shut down and restart...now am even afraid to run it again...
what may be the problem?
one other question..I use bull guard antivirus..and sometimes when i run my code...bullguard sees my code as a virus and quarantines it...damn..that antivirus is too aggressive...or is it that there is really a virus hiding somewhere???
ps: i disattivated bullguard before the freezing thing started so i dont think is correlated...
thanks...

Post the code to see what you are trying to run, also it might be your compiler.
as did Hertz said before post the code... about the virus issue, dont worry about that, there is no virus in programs that you create, only if your pc is infected, i have avast antivirus and he too recognizes my programs as viruses, but i just deactivate it when i work, you should do it to i think.
switch to linux
mm metulburr...i wanted to run linux side by side my windows but this lenovo pc doesnt allow me to partition..the fuckk....so i just use virtualbox...not that fast...i may try do it in there...anyway this is the code...a simple one too...got me thinking lol..as am just a beginner... so i have tmat int tmat [5][5] = {{1,2,3,4,4,},
{7,4,5,7,6,},
{4,0,7,9,0,},
{4,5,5,9,0,},
{4,5,9,9,0,},
};

at the end of running i want written to file
1, 2, 3
4, 5, 6,
4, 7, 9
4, 7, 9,
4, 9, 0,
I mean i just want to extract the numbers which don't repeat themselves into another matrix i called tcopy....

4, 5, 0,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

const int R = 5;
const int C = 5;
const int R1 = 3;
const int C1 = 3;
	int rr = 0, cc = 0, i= 0, control = 0, st_c = 0, st_r = 0, a= 0;
	vector<int>vec;
void extract (int mat [R][C]);
void filling (int mat [R1][C1], int value);
void cross_checking (vector<int>container);
int tcopy [3][3];
int main (){
	

    int tmat [5][5] = {{1,2,3,4,4,},
                       {7,4,5,7,6,},
                       {4,0,7,9,0,},
                       {4,5,5,9,0,},
                       {4,5,9,9,0,},
                       };

extract(tmat);

fstream file;
file.open("oppose.txt", ios::in | ios::out);
if (file.is_open()){
    for(int k= 0; k< 3; k++)
        for(int i = 0; i <3; i++)

        file<<tcopy[k][i]<<", ";
        cout<<"copied to file successfully!";
    file.close();
}


                        }

void extract (int mat [R][C]){
for (int move= 0; move<(R*C); move++)
{    for (; i < R;)
     for (int c= 0; c < C; c++) 
     { vec.push_back(mat[i][c]) ;}
     cross_checking(vec); 
     i++; 
 }
}

void cross_checking (vector<int>container){
vector<int>::iterator itr, itr1;
int a , k;
for ( a = 0; a < container.size(); a++)
{ int k = container[a];
for (itr = container.begin(); itr != itr1; ++itr) 
{if (*itr!=k){filling (tcopy, *itr);} }
     }
}

void filling (int mat [R1][C1], int value)
{ 
    mat[rr][cc] = value;
    if (cc < C1) cc++;
    else { cc = 0;
    if(rr<R1) rr++;}
}
Run through a debugger, then interrupt the program and see where it is.

Also, learn to indent and limit the scope of your variables
@ne555 what do you mean by indent and limiting scope of variables? thank you...and i've been trying to use the code::blocks debugger but am not making it work...the tutorial says after clicking on start debugging a debugging window should open but nothing happens...the log window just tell me debugging is complete with status zero.... i cant make nothing out of that...not helping me learn the debugging thing...i had wanted to try it on dev c++ but ppl are saying is now obsolete...
Last edited on
http://en.wikipedia.org/wiki/Indent_style
By instance, your function cross_checking() is unreadable.

About limiting the scope, you've got a variable `i' that's used only in extract() as a counter. ¿why is it global?


> and i've been trying to use the code::blocks debugger but am not making it work
RTFM
As a bonus, the problem is in the extract() function, infinite loop in lines 45-47
ne555 :) , I understand you dont want to do my dirty work for me...and you want me to think...and i appreciate...just dont abandone me...:) help me thru...now am looking very hard but i cant see why I should get locked up in that loop of function extract... about i being global..i made it like that because i dont want it being initialized all the time extract starts...i takes care of the row, if i place int i, in extract..anytime extract starts then the position of i will go back to row zero and i dont want that...it must keep on increasing till R-1...

(by instance, your function cross_checking() is unreadable) you mean you can't read that function and understand? or is my compiler that can't read? lemme try to explain cross_checking...first for loop..a starting from zero...container[a] should be assigned to k...then we enter into a new loop...now starting from the beginning of the container, if a is equal to other numbers in the container..dont put it into tcopy...else all other numbers not equal to container[a], should be placed in tcopy...when itr becomes equal to itr1...that loops break and we come out...then a is increased...so we repeat the same thing..comparing and filling tcopy...at the end the loop should break and we come out...
this is the idea... where am I really going wrong...my eyes are even going a lil bit blurry....lol
where am I really going wrong...my eyes are even going a lil bit blurry

Well - that's exactly why a consistent style of indentation was recommended, it makes the structure of the code more visibly obvious, without so much stress on either eyesight or braincells - it's not just to make the code look pretty, its an effective tool to make working with code easier.
Topic archived. No new replies allowed.