• 0

problem with geany C++ compiler on linux


Question

I am havin problems with this compiler..i really Like geany but I am gettin errors. This program runs on DEvcpp compiler on my windows but on geany I am gettin errors can u guys help me this is my program

#include<iostream>



#include<fstream>



#include<string>



#include<iomanip>



#include<cmath>







using namespace std;







struct MATRIX {



	   double a11, a12,a21, a22;



			  };







void file_open(ofstream &Out);



int file_close(ofstream &Out);







void print_matrix(MATRIX m, char word[], ofstream &out);



void get_matrix(MATRIX &matrix, char name[]);



void get_scalar(double &k);



void calc_sum(MATRIX m1, MATRIX m2, MATRIX ∑);



void calc_diff(MATRIX m1, MATRIX m2, MATRIX &diff);



void scalar_mult(double k, MATRIX m, MATRIX &km);



void calc_prod (MATRIX m1, MATRIX m2, MATRIX ∏);



void calc_inverse(MATRIX m, MATRIX &inverse);







int main()



{







MATRIX matrix1, matrix2, sum, difference, product,inverse, sMult;



double k=4.5;



char name1[20], name2[20];







ofstream outfile;







	file_open(outfile);







get_matrix(matrix1, name1);



get_matrix(matrix2, name2);



get_scalar(k);   







calc_sum(matrix1, matrix2, sum);	



calc_diff(matrix1,matrix2,difference);	



scalar_mult (k, matrix1, sMult);



calc_prod(matrix1, matrix2, product);  



calc_inverse(matrix1, inverse);







	print_matrix(matrix1, name1,outfile);



	print_matrix(matrix2, name2,outfile);



	print_matrix(sum,  "Sum =", outfile);



	print_matrix(difference, "Difference = ", outfile);



	print_matrix(sMult, "Scalar Product = ", outfile);



	print_matrix(product, "Matrix Product = ", outfile);



	print_matrix(inverse, "Inverse  = ", outfile);



















file_close(outfile);



return 0;



}











void get_matrix(MATRIX &matrix, char name[])



{



	 cout<<"Enter the name of the Matrix :";



	 cin>>ws;



	 cin.getline(name,20);



	 cout<<"Enter m1: ";



	 cin>>matrix.a11;



	 cout<<"Enter m2: ";



	 cin>>matrix.a12;



	 cout << "Enter m3: ";



	 cin >> matrix.a21;



	 cout<<"Enter m4: ";



	 cin>>matrix.a22;



}



void get_scalar(double &k)



{



	 cout<<endl<<"Enter scalar value: ";



	 cin>>k;



}	 







void calc_sum(MATRIX m1, MATRIX m2, MATRIX ∑)



{



	 sum.a11 = m1.a11 + m2.a11;



	 sum.a12 = m1.a12 + m2.a12;



	 sum.a21 = m1.a21 + m2.a21;



	 sum.a22 = m1.a22 + m2.a22;



}



void calc_diff(MATRIX m1, MATRIX m2, MATRIX &diff)



{



	 diff.a11 = m1.a11 - m2.a11;



	 diff.a12 = m1.a12 - m2.a12;



	 diff.a21 = m1.a21 - m2.a21;



	 diff.a22 = m1.a22 - m2.a22;



}



void scalar_mult(double k, MATRIX m, MATRIX &km)



{



	 km.a11 = m.a11 * k;



	 km.a12 = m.a12 * k;



	 km.a21 = m.a21 * k;



	 km.a22 = m.a11 * k;



}



void calc_prod (MATRIX m1, MATRIX m2, MATRIX ∏)



{



	 prod.a11= m1.a11 * m2.a11 + m1.a12 * m2.a21;



	 prod.a12= m1.a11 * m2.a11 + m1.a12 * m2.a21;



	 prod.a21= m1.a11 * m2.a11 + m1.a12 * m2.a21;



	 prod.a22= m1.a11 * m2.a11 + m1.a12 * m2.a21;



}







void calc_inverse(MATRIX m, MATRIX &inverse)



{



	 double det = m.a11 * m.a22 - m.a21 * m.a12;



	 inverse.a11 = m.a22/det;



	 inverse.a12 = -(m.a12/det);



	 inverse.a21 = -(m.a21/det);



	 inverse.a22 =  m.a11/det;







} 







void print_matrix( MATRIX matrix, char word[], ofstream &out)



{





	 out << word << " = " << matrix.a11 << "  " << matrix.a12 << "\n"



			<< "	"<< matrix.a21 << "  " << matrix.a22 << "\n";







}







void file_open(ofstream &Out)



{



	int choice;







	char drive[3]; 



	char disk_f[20]; 



	char file[15];







	cout<< "Output to console [1] to disk file [2]:  ";



	cin >> choice;



	if(choice == 1)



			{



				Out.open("con





				}



	else



	{



		cout<< "Which drive would you want to save your data?";







		cin >> drive;



		strcpy(disk_f, drive);



		strcat(disk_f, ":");



		cout<< "Please enter result file name: ";



		cin >>file;



		strcat(disk_f, file);



		strcat(disk_f, ".dta");



		Out.open(disk_f);



		}







	Out<<setiosflags(ios::showpoint|ios::fixed)<<setprecision(2);







	}







int file_close(ofstream &Out)



	{

int flag;

	Out.close();

cin>>flag;

	return 0;



		}

the errors

  Quote
matrix.cpp:103:27: warning: character constant too long for its type

matrix.cpp: In function ?int main()?:

matrix.cpp:95: warning: deprecated conversion from string constant to ?char*?

matrix.cpp:97: warning: deprecated conversion from string constant to ?char*?

matrix.cpp:99: warning: deprecated conversion from string constant to ?char*?

matrix.cpp:101: warning: deprecated conversion from string constant to ?char*?

matrix.cpp:103: error: invalid conversion from ?int? to ?char*?

matrix.cpp:103: error: initializing argument 2 of ?void print_matrix(MATRIX, char*, std::ofstream&)?

matrix.cpp: In function ?void file_open(std::ofstream&)?:

matrix.cpp:296: error: ?strcpy? was not declared in this scope

matrix.cpp:298: error: ?strcat? was not declared in this scope

by the way maybe you guys know better compilers and much easier and good :0

thanks for help

7 answers to this question

Recommended Posts

  • 0

Geany is just a text editor... he is using GCC whether he knows it or not. Read up on type conversions in C++. Also a few of your header files must include the ".h" extension, I know iostream doesn't need the .h but i'm positive string needs the extension and maybe some of the others. Good luck.

  • 0
  mzawieska said:
it works but I am still gettin warning ...the program works only for input ( I type all the information) then its not outputing anyything

any ideas why?

Did you look at what I said in your other thread about this?

char g
cin >> g

You need to use cin stop the console window closing

  Tech God said:
Geany is just a text editor... he is using GCC whether he knows it or not. Read up on type conversions in C++. Also a few of your header files must include the ".h" extension, I know iostream doesn't need the .h but i'm positive string needs the extension and maybe some of the others. Good luck.

You're right Geany is a text editor, but as you say, also has the compatibility to compile using C and C++.

I'm fairly sure that you shouldn't have the .h for string header file. String.h and cstring are for using strings in C code, not C++. I'll try and find where I read that...

Edited by ViZioN
  • 0

strcopy & strcat is for c style strings so you would need to #include cstring

http://www.cplusplus.com/reference/clibrary/cstring/

It might help if you edit your post to include some better formated code because as it is right now it's nearly IMPOSSIBLE to read. Also no matter what compiler you use if your program is coded wrong it's not going to work; there is no "easier" complier (at least there shouldn't be). Different IDE's and editers may make your life easier with syntax highlighting or code completion but they don't program for you. A lot of people prefer to use emacs or vim in linux but those two programs have steep learning curves (but eventually you need to learn at least one of them if your serious about programming). Netbeans is an okay IDE on the Linux system Gedit with syntax highlight is nice too.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Ironically, I do have audio engineering experience, but still find the different flavors of VB-Audio's VoiceMeeter (and more advanced options like Banana and Potato) to be a little unintuitive. Yes, I can figure them out, but despite having a UI that looks like an audio mixer, they don't exactly follow typical audio mixing conventions, so it takes a little time to figure out how the software works. Still, I feel like for what you are asking for, VoiceMeeter is a good solution. If you're interested, I could probably create a quick how-to video.
    • If it was not for AI push, you have a point but as I already use notepad++ and I really don’t see the need for all the extras in a damn NOTEPAD… I also disagree real notepad with pen does not offer spell check, so why NOTEPAD app should? you already have free Word online.. if this is what you need.
    • How is it "one of the best file managers in Windows"? It is slow as hell and crashes like it's the offspring of Windows Me
    • Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked] "{e2bf9676-5f8f-435c-97eb-11607a5bedf7}"="Share" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked] "{e2bf9676-5f8f-435c-97eb-11607a5bedf7}"="Share" [-HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\ModernSharing] Remove that Share text.
    • Meh could never use the UWP as I use WhatsApp business and it's features are available on the standard. Thos this applies to both windows and macos+ipad versions. So I'm stuck on using web versions for whatever platform.
  • Recent Achievements

    • Rookie
      Snake Doc went up a rank
      Rookie
    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      497
    2. 2
      Michael Scrip
      205
    3. 3
      ATLien_0
      201
    4. 4
      Xenon
      138
    5. 5
      +FloatingFatMan
      117
  • Tell a friend

    Love Neowin? Tell a friend!