Dev C++ Stops working

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 7769 Views - Last Post: 26 April 2010 - 03:46 PM Rate Topic: -----

#1 john2223322  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-February 10

Dev C++ Stops working

Posted 26 April 2010 - 10:20 AM

When I run my program, the menu comes up, I press one, I am prompted to input the file name and when I input the filename and press enter, I get the message "(whatever).exe" has stopped working. does anyone know what might be causing this problem? Thankyou.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int Menu(); // Menu Function
void InpFile(); // Inputs from file
void RowMajor(); // Print Matrix Row Major Function
void ColMajor(); // Print Matrix Column Major Function
void AvgCol(); // Average a column function
void PrintRange(); // Print Range Function
void AddMat(); // Add two matrices

int main(){
    
    
    int choice = Menu();
    while (choice != 0){
        switch(choice){
             case 1: // Input Matrices
             InpFile();
             case 2: // Print Matrix Row Major
             case 3: // Print Matrix Column Major
             case 4: // Average a column
             case 5: // Print Range
             case 6: // Add two matrices
             case 7: // exit
             default: cout << "Invalid selection!" << endl;
             } // switch close
        choice = Menu();
    } // while (choice != 0)
    
    
    
    system ("pause");
    } // int Main ()
    
// ***********************************************  
int Menu(){
    int choice;
    cout << "Please make a selection: " << endl;
    cout << "1. Input from two files" << endl;
    cout << "2. Print Matrix Row Major" << endl;
    cout << "3. Print Matrix Column Major" << endl;
    cout << "4. Average a Column" << endl;
    cout << "5. Print Range" << endl;
    cout << "6. Add two matrices" << endl;
    cout << "7. Quit" << endl;
    cin >> choice;
    return choice;
    } // closes int Menu
// ***********************************************

//************************************************
void InpFile(){
     cout << "What is the name of the first file?" << endl; // Ask the user for the name of the first data file to use
     string filename1;
     cin >> filename1;
     int r;
     int c;
     int input;
     int array[r][c];
     
    
     ifstream file1;
     file1.open(filename1.c_str());
     
     if(file1.fail()){
          cout << "File Not Found" << endl;
          system ("pause");
          exit(1);
          } // if(file1.fail()){
    
     
     while(!file1.eof()){
          file1 >> input;
          int r = input;
          file1 >> input;
          int c = input;
          file1 >> input;
          array[0][0];
          file1 >> input;
          array[0][1];
          file1 >> input;
          array[0][2];
          file1 >> input;
          array[1][0];
          file1 >> input;
          array[1][1];
          file1 >> input;
          array[1][2];
          file1 >> input;
          array[2][0];
          file1 >> input;
          array[2][1];
          file1 >> input;
          array[2][2];
         
          } // while(!file1.eof())
          cout << array;
     
    
     } // Inpute from file
//************************************************

// ***********************************************
void RowMajor(){} // Print Matrix Row Major Function
// ***********************************************

// ***********************************************
void ColMajor(); // Print Matrix Column Major Function
// ***********************************************

// ***********************************************
void AvgCol(); // Average a column function
// ***********************************************

// ***********************************************
void PrintRange(); // Print Range Function
// ***********************************************

// ***********************************************
void AddMat(); // Add two matrices
// ***********************************************



Is This A Good Question/Topic? 0
  • +

Replies To: Dev C++ Stops working

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:25 AM

I know what the problem is.
Was This Post Helpful? 0
  • +
  • -

#3 john2223322  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-February 10

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:28 AM

Do you know how to fix it?
Was This Post Helpful? 0
  • +
  • -

#4 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:29 AM

Yes I do. I can write your whole program for you too!
Was This Post Helpful? 0
  • +
  • -

#5 john2223322  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-February 10

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:32 AM

If I were asking you to write the whole program for me that would be nice. However, in this situation it would be irrelevant as I am just asking for the problem to be identified.
Was This Post Helpful? 0
  • +
  • -

#6 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:35 AM

Aren't you the least bit curious how I identified the problem? I mean, I've never seen your code before. I'm not working on your assignment. How could I possibly have looked at your code and within 10 seconds identified the problem?
Was This Post Helpful? 0
  • +
  • -

#7 john2223322  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-February 10

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:39 AM

The same way a petrologist could identify a rock within 10 seconds of looking at it. This probably isn't the first time you've seen this error. So, by scanning the code it was evident to you. I have no idea if it's a virus I have on my computer or a syntax error that is causing that. Knowing which it was would narrow it down to help me identify what the problem is and then know why it is an error.
Was This Post Helpful? 0
  • +
  • -

#8 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:47 AM

Quote

The same way a petrologist could identify a rock within 10 seconds of looking at it.
Bzzz. Wrong! It's not a memory or knowledge test, to figure out the source of the problem.

Quote

This probably isn't the first time you've seen this error.
I don't think I can recall seeing your mistake before. I guess I can recall the mistakes that lead up to your mistake, but it wasn't a memory trick. I'm not solving your problem because I saw it before.

Quote

So, by scanning the code it was evident to you
Yes, it was. I read your code. It said something wrong.

Quote

I have no idea if it's a virus I have on my computer or a syntax error that is causing that.
It's not a syntax error, because it compiles. But what's the likelihood you wrote correct code. Think about it, you are a beginner. What's more likely. A virus specifically designed to stop this program you personally wrote, or a mistake you made?

Quote

Knowing which it was would narrow it down to help me identify what the problem is and then know why it is an error.
Really? Well, I can tell you it's not a virus then :) You made a mistake. It's not a syntactical mistake. But your program does something incorrect. Because you programmed it that way.

I am asking this because debugging is also a part of your task as a programmer. So I'm wondering why you didn't debug. It seems you think being able to debug is a question of knowledge. It's not. I can tell you that you can solve your problem with everything you know so far, and an ability to think (your brain), and some time. It will take you longer than me, but you can do it.

Be confident in yourself. If you can write this code, you can figure out what's wrong with it too. I know the answer, so I know it's not something obscure that only special knowledge can help solve. You can do it!
Was This Post Helpful? 1
  • +
  • -

#9 john2223322  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-February 10

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:55 AM

We haven't debugged programs before. We just write the code and then compile+run it. However, I did as you instructed and debugged it, (I think), and it comes up with a "An Access Violation(Segmentation Fault) raised in your program". Is this on the right track?
Was This Post Helpful? 0
  • +
  • -

#10 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Dev C++ Stops working

Posted 26 April 2010 - 10:59 AM

Quote

We haven't debugged programs before. We just write the code and then compile+run it.
Well time to learn. To understand how critical debugging is, it's a bit like reading. Imagine a writer who writes, but never reads or proofreads his own writing. How good do you think his books will be? Probably not very!

Quote

However, I did as you instructed and debugged it, (I think)
Well, what does "debugged it" mean? Decribe the steps you took to "debug".

Quote

it comes up with a "An Access Violation(Segmentation Fault) raised in your program". Is this on the right track?
I don't know, until you describe the steps you took. Can you "break" from this exception dialog?
Was This Post Helpful? 1
  • +
  • -

#11 john2223322  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-February 10

Re: Dev C++ Stops working

Posted 26 April 2010 - 11:01 AM

to debug , I just clicked the "debug" button in the tool bar and it ran the program, I typed the filename and thats when the error came up.
Was This Post Helpful? 0
  • +
  • -

#12 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Dev C++ Stops working

Posted 26 April 2010 - 11:03 AM

Quote

to debug , I just clicked the "debug" button in the tool bar and it ran the program,
That sounds like you're doing the right thing. By the way, what IDE (program) are you using the create your C++ programs? That way, I know what debugger you have access to as well.
Was This Post Helpful? 0
  • +
  • -

#13 john2223322  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-February 10

Re: Dev C++ Stops working

Posted 26 April 2010 - 11:05 AM

I'm using Dev C++ 4.9.9.2
Was This Post Helpful? 0
  • +
  • -

#14 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Dev C++ Stops working

Posted 26 April 2010 - 11:08 AM

Quote

I'm using Dev C++ 4.9.9.2
Erghhh. I was hoping you wouldn't say this. Oh, well. Actually, I haven't touched Dev-C++ in a while (by which I mean nearly a decade), so I have to take some to familiarize myself. I can show you how to debug in VC++ 2010, if you're interested. (And really, VC++ 2010 is a much better compiler to work with). But, if not, I'll go ahead and setup DevC++ for myself.
Was This Post Helpful? 0
  • +
  • -

#15 john2223322  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-February 10

Re: Dev C++ Stops working

Posted 26 April 2010 - 11:09 AM

We just use Dev C++ in class so that's all I've messed with.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2