0

please help to with this program by mainly using arrays and pointers ,... i need this program to check 2 matrix files "if they contain any character and if they contain cout<<"invalid"; " and to open them from .txt file

#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
using namespace std;

int main()
{
 char y, n; 
 ifstream file1;
 ifstream file2;
 string filename1;
 string filename2;
 string c;
 int number;
 int choice;

cout<<"xxxxxxx matrix calculator \n";
cout<<"please choose from the following menu :\n";

while(choice!=8&&choice==n)
{
 cout<<"1. matrix addition\n";
 cout<<"2. matrix subtraction\n";
 cout<<"3. matrix multiplication\n";
 cout<<"4. matrix transpose\n";
 cout<<"5. checking matrix equality\n";
 cout<<"6. check matrix properties\n";
 cout<<"7. matrix power\n";
 cout<<"8. exit\n";
 cout<<"please enter your choice\n";
 cin>>choice;

 while(//condition when there is character)// for the first file and the second one :D
         {                   
                            cout<<"invalid file!!\n";
                            cout<<"do you want to continue (y) or return to menu(n)\n"; 
/* "y" to continue to try to enter the file name again & "n" to go back to the menu*/
                            cin>>choice1;
                            if(choice1=='y')
                            {
                             cout<<"please enter the first filename\n";
                         cin>>filename1;
                          file1.open(filename1.c_str(),ios::in);
                          
                                 if(!file1.fail())
                                 {
                                                 cout<<"good\n";
                                                 break;
                                                 }
                          }
                          else if(choice1=='n')
                          {
                               cout<<"assdasdasdad\n";
                              break;
                               }   
                               }
         


 switch(choice)
{
 case 1 :
          
 case 2 :
      
 case 3 :
      
 case 4 :
 
 case 5 :
 
 case 6 :
      
 case 7 :
 
 case 8 :
      cout<<"thank you for using my program\n";
      exit(1);
      }

 system ("pause");
 return 0; 
}
}
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Nick Evan
1

First of all: a thread called helpzz plzzz fast cuz im NOOB, is not really a great way to explain your problem. Clear titles make people help you faster.

Next: Please use code tags. It makes your code easier to read

Please click

Then for your program. There are quite a lot of things wrong with it.
For example: char y,n; you are declaring 2 chars named 'y' and 'n', but they never get a value. Choice never gets a input. What you want is something like:

char choice = 'x'; //give it some value
	while (choice < '0' || choice > '8') 	
               choice = cin.get(); // loop until good input

Adjust the code above to fit your program.

Votes + Comments
Say it bro, say it loud and often!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.