473,811 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

im trying to finish a program just before the deadline

im trying to finish a program, but been having some dificulties in passing
a bidimensional array at a function...(til now nobody could help me) final
result should be a program that adds, subtracts and multiply two arrays,
but havent been able to do the rest once that this is right in the basis
of the program... this is what have done so far (sorry for the bad "Eng"
im trying but im portuguese so people say i sound like "Borat")!

#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <fstream.h>
#include <ctype.h>

using namespace std;

//mxa
int L1;
int C1;

//mxb
int L2;
int C2;

void menu ();
void mxa ();
void mxb ();
void calc ();

void mxa (){
// A

cout<< "Matrix A" << endl;
cout<< "Lines:" << endl;
cin >>L1;
cout<< "Colums:" << endl;
cin>> C1;
int mx1 [L1][C1];
cout<<endl;
for (int m=0; m<L1; m++){
for (int n=0; n<C1; n++){
cout<< " Matrix element " << m+1 << " , " << n+1 <<endl;
cin>> mx1 [m][n];
cout<< endl;}}

for (int m=0; m<L1; m++){
for (int n=0; n<C1; n++){
cout<< mx1 [m][n]; }
cout<<endl;}

calc (mx1)
mxb();

}//Eo A

void mxb (){
//B

cout<< "Matrix B" << endl;
cout<< "Lines:" << endl;
cin>> L2;
cout<< "Colums :" << endl;
cin>> C2;
int mx2 [L2][C2];
cout<<endl;

for (int m=0; m<L2; m++){
for (int n=0; n<C2; n++){
cout<< "Matrix element " << m+1 << " , " << n+1 <<endl;
cin>> mx2 [m][n];
cout<< endl;}}

for (int m=0; m<L2; m++){
for (int n=0; n<C2; n++){
cout<< mx2 [m][n]; }
cout<<endl;}

calc (mx2);
}//Eo B

void calc (int a[][C1], int b[][C2]){ // <-------------------
/*
Here is the tricky part, for what i've seen and read i believe
that this should be right but unfortunately it just doesnt work
//using Dev-C++ 4.9.9.0>
*/

system("cls");
}//Eo calc

void menu (){
int opt;
cout<< "Main menu:" << endl;
cout<< "1 - Mx A" << endl;
cout<< "2 - Mx B" << endl;
cout<< "3 - Calc "<< endl;
cin>> opt;
if (opcao == 1) {mxa();}
else if (opcao ==2) {mxb ();}
else if (opcao == 3) { calc ();}

}//Eo Mmenu

int main(){
system("cls");
cout<< "Mx Calc 0.9 RC"<< endl;
cout<< "************** **"<< endl;
cout<< endl;

menu ();

system("PAUSE") ;
return 0;
}
Nov 14 '05 #1
2 1740
<4d************ *************** ***@localhost.t alkaboutprogram ming.com>
giambi <gi****@sapo.pt > wrote:
#include <iostream>
In the future, C++ questions go to comp.lang.c++. You've also posted
much more code than is relevant to your problem, making the crux of
your question more difficult to discern.
#include <conio.h>
Non-standard header - not kosher for either comp.lang.c or
comp.lang.c++.

But on to the real issue...
int L1;
int C1; void calc (int a[][C1], int b[][C2]){ // <-------------------

^^ ^^

In C, these must be compile-time constants (the phrase "integral
constant" may apply...), and the same may also hold in C++ (I've
crossposted there in case I am incorrect). If you pass an int**, you
should be fine, although the use of global variables isn't the best
way to tackle this.

--
Christopher Benson-Manica
ataru(at)cybers pace.org
Nov 14 '05 #2
(c.l.c restored, as C answer wasn't complete and I don't read ++)
On Tue, 4 Jan 2005 23:05:59 +0000 (UTC), Christopher Benson-Manica
<at***@nospam.c yberspace.org> wrote:
<4d************ *************** ***@localhost.t alkaboutprogram ming.com>
giambi <gi****@sapo.pt > wrote:
#include <iostream>


In the future, C++ questions go to comp.lang.c++. You've also posted
much more code than is relevant to your problem, making the crux of
your question more difficult to discern.
#include <conio.h>


Non-standard header - not kosher for either comp.lang.c or
comp.lang.c++.

But on to the real issue...
int L1;
int C1;

void calc (int a[][C1], int b[][C2]){ // <-------------------

^^ ^^

In C, these must be compile-time constants (the phrase "integral
constant" may apply...), and the same may also hold in C++ (I've
crossposted there in case I am incorrect). If you pass an int**, you
should be fine, although the use of global variables isn't the best
way to tackle this.


In C99 (or ganuck) they may be runtime (but positive) expressions. In
C++, as in C89, they must be integral constant expressions; C++ is
more liberal as to what is an i.c.e. but this case still isn't.

Using an int** _which you have set to point to correctly allocated
space(s)_ is one solution. In C++, another is nested std::vector<>, or
a new'ed array of std::vector but that's yucky.
- David.Thompson1 at worldnet.att.ne t
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

72
6999
by: Wim Vanhoof | last post by:
Dear all, I would like to announce that the department of computer science of the University of Namur, Belgium, is seeking a post-doctoral researcher for a one-year fellowship in the area of (logic-based) program development, analysis and transformation.
8
2094
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is, I've been playing with Qt in KDE on a Slackware 10.0 system, and following their cookbook exercises, and everything's working, and I have no clue what the code is doing, i.e.. how do I connect my brain to the ascii in the files to the stuff on...
21
2255
by: tyler_durden | last post by:
hi there peeps... like I say in the topic, I need to do an e-mail program in C language, and has to be made until the 3th of january..the problem is I'm having some problems with it. I was wondering if someone had a program like this..it has to send e-mails, read e-mails from a .txt file and show them in the screen with the subject, date, etc... can someone please help me out? thanks
0
1519
by: Piotr Nienaltowski | last post by:
!!! DEADLINE FOR PAPER SUBMISSIONS HAS BEEN EXTENDED UNTIL FEBRUARY 26, 2004 !!! ---------------------------------------------------------------- .NET TECHNOLOGIES 2004 2nd International Workshop on .NET Technologies University of West Bohemia Pilsen (Czech Republic) May 31 - June 2, 2004
4
8414
by: Dylan Parry | last post by:
Hi folks, I'm writing a program that needs to execute an external program and wait for it to finish running before it can make use of the output from that program. Specifically, the external program converts from one file format to another, and is something that I can't do natively :( So what I need to figure out is how to: a) Start the external program, with parameters
2
1543
by: rahulthathoo | last post by:
Hi I have a perl program called by my php script, which in turn is called by the browser. Now, the perl program is called using exec, but takes a long time to finish. So, till the time the perl script does not finish its job, the browser does not show anything. I have messages like "Dont close this window", but that does not show up till the whole perl program finishes. Is there a way, I can somehow remedy this, try to show a message on...
5
6164
by: Jim | last post by:
I have a form in an Access 2003 db that calls (using shell - thanks to this newsgroup) a Vb.net program I wrote to parse a text file. The call works fine. The VB parses the file correctly. How do I get the Access form to wait for the VB program to finish? Can the vb pass code back to Access? Can Access check somehow to see if VB is closed? I'm a VB.net newbie.
0
1131
by: john | last post by:
SETP-08 Draft paper submission deadline is just few days from now The 2008 International Conference on Software Engineering Theory and Practice (SETP-08) (website: www.PromoteResearch.org ) will be held during July 7-10 2008 in Orlando, FL, USA. We invite draft paper submissions and deadline for submission is extended until February 19 2008 due to several requests from the authors. The conference will be held at the same time and...
0
1231
by: john | last post by:
EISWT-08 Draft paper submission is deadline is just few days from now The 2008 International Conference on Enterprise Information Systems and Web Technologies (EISWT-08) (website: www.PromoteResearch.org ) will be held during July 7-10 2008 in Orlando, FL, USA. We invite draft paper submissions and the deadline is extended until February 19 2008 due to several requests from the authors. The conference will be held at the same time and...
0
9728
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.