Hi all
I am using DEVCPP 4.9.8.1 which uses MingW32 GCC 3.2 compiler
I am trying to compile this program, but without success, I am sure the
compiler is set up ok, as I can compile and run hello.cpp fine
here is the listing please can someone tell what I am doing wrong please
#include <iostream>
#include <cstdlib>
using namespace std;
int integerPower ( int, int ) ;
int main( void )
{
int x, y ;
cout << "First enter the base number, folowed by the component: " << endl
;
cin >> x, y ;
cout << integerPower ( x, y ) << endl ;
int integerPower ( int base, int component )
{
int ans = base ;
for ( i = component; i >=1; --i )
{
ans *= base ;
}
return ans;
}
system("PAUSE");
return 0;
}
and here is the compile log
Compiler: Default compiler
Building Makefile: "M:\C++\How To Program\CH03\Ex3_18\Makefile.win"
Executing make...
make.exe -f "M:\C++\How To Program\CH03\Ex3_18\Makefile.win" all
g++.exe -c ex3_18.cpp -o
x3_18.o -I"K:/Eric/Dev-Cpp/include/c++" -I"K:/Eric/Dev-Cpp/include/c++/ming
w32" -I"K:/Eric/Dev-Cpp/include/c++/backward" -I"K:/Eric/Dev-Cpp/include"
ex3_18.cpp: In function `int main()':
ex3_18.cpp:18: parse error before `{' token
ex3_18.cpp:20: `component' undeclared (first use this function)
ex3_18.cpp:20: (Each undeclared identifier is reported only once for each
function it appears in.)
ex3_18.cpp:22: `ans' undeclared (first use this function)
ex3_18.cpp:22: `base' undeclared (first use this function)
ex3_18.cpp: At global scope:
ex3_18.cpp:27: ISO C++ forbids declaration of `system' with no type
ex3_18.cpp:27: `int system' redeclared as different kind of symbol
K:/Eric/Dev-Cpp/include/stdlib.h:373: previous declaration of `int
system(const
char*)'
ex3_18.cpp:27: invalid conversion from `const char*' to `int'
ex3_18.cpp:28: parse error before `return'
make.exe: *** [ex3_18.o] Error 1
Execution terminated
I notice that it is moaning about component, which is being passed in to the
function as an argument, I didnt think I needed to declare component first,
as I have already done so in the function prototype, like I say this one has
confused me
TIA 4 2380
"Rich" <RE**************@yahoo.co.uk> wrote in message
news:bf**********@pheidippides.axion.bt.co.uk... Hi all
I am using DEVCPP 4.9.8.1 which uses MingW32 GCC 3.2 compiler
I am trying to compile this program, but without success, I am sure the compiler is set up ok, as I can compile and run hello.cpp fine
here is the listing please can someone tell what I am doing wrong please
#include <iostream> #include <cstdlib>
using namespace std;
int integerPower ( int, int ) ;
int main( void ) { int x, y ;
cout << "First enter the base number, folowed by the component: " <<
endl ; cin >> x, y ;
cout << integerPower ( x, y ) << endl ;
You can define a function within a function or indeed main(), so remove from
here
int integerPower ( int base, int component ) { int ans = base ; for ( i = component; i >=1; --i ) { ans *= base ; }
return ans; }
to here, and then place it at the end of the file
Allan
system("PAUSE"); return 0; }
and here is the compile log
Compiler: Default compiler Building Makefile: "M:\C++\How To Program\CH03\Ex3_18\Makefile.win" Executing make... make.exe -f "M:\C++\How To Program\CH03\Ex3_18\Makefile.win" all g++.exe -c ex3_18.cpp -o
3_18.o -I"K:/Eric/Dev-Cpp/include/c++" -I"K:/Eric/Dev-Cpp/include/c++/ming
32" -I"K:/Eric/Dev-Cpp/include/c++/backward" -I"K:/Eric/Dev-Cpp/include" ex3_18.cpp: In function `int main()': ex3_18.cpp:18: parse error before `{' token
ex3_18.cpp:20: `component' undeclared (first use this function) ex3_18.cpp:20: (Each undeclared identifier is reported only once for each function it appears in.) ex3_18.cpp:22: `ans' undeclared (first use this function) ex3_18.cpp:22: `base' undeclared (first use this function)
ex3_18.cpp: At global scope: ex3_18.cpp:27: ISO C++ forbids declaration of `system' with no type
ex3_18.cpp:27: `int system' redeclared as different kind of symbol K:/Eric/Dev-Cpp/include/stdlib.h:373: previous declaration of `int system(const char*)' ex3_18.cpp:27: invalid conversion from `const char*' to `int' ex3_18.cpp:28: parse error before `return'
make.exe: *** [ex3_18.o] Error 1
Execution terminated
I notice that it is moaning about component, which is being passed in to
the function as an argument, I didnt think I needed to declare component
first, as I have already done so in the function prototype, like I say this one
has confused me TIA
Allan Bruce wrote: "Rich" <RE**************@yahoo.co.uk> wrote in message news:bf**********@pheidippides.axion.bt.co.uk...
Hi all
I am using DEVCPP 4.9.8.1 which uses MingW32 GCC 3.2 compiler
I am trying to compile this program, but without success, I am sure the compiler is set up ok, as I can compile and run hello.cpp fine
here is the listing please can someone tell what I am doing wrong please
#include <iostream> #include <cstdlib>
using namespace std;
int integerPower ( int, int ) ;
int main( void ) { int x, y ;
cout << "First enter the base number, folowed by the component: " << endl
; cin >> x, y ;
cin >> x >> y; cout << integerPower ( x, y ) << endl ;
You can define a function within a function or indeed main(), so remove from
^^^^^
can't
here
int integerPower ( int base, int component ) { int ans = base ; for ( i = component; i >=1; --i ) { ans *= base ; }
return ans; }
to here, and then place it at the end of the file Allan system("PAUSE"); return 0; }
and here is the compile log
Compiler: Default compiler Building Makefile: "M:\C++\How To Program\CH03\Ex3_18\Makefile.win" Executing make... make.exe -f "M:\C++\How To Program\CH03\Ex3_18\Makefile.win" all g++.exe -c ex3_18.cpp -o
3_18.o -I"K:/Eric/Dev-Cpp/include/c++" -I"K:/Eric/Dev-Cpp/include/c++/ming
32" -I"K:/Eric/Dev-Cpp/include/c++/backward" -I"K:/Eric/Dev-Cpp/include"
ex3_18.cpp: In function `int main()': ex3_18.cpp:18: parse error before `{' token
ex3_18.cpp:20: `component' undeclared (first use this function) ex3_18.cpp:20: (Each undeclared identifier is reported only once for each function it appears in.) ex3_18.cpp:22: `ans' undeclared (first use this function) ex3_18.cpp:22: `base' undeclared (first use this function)
ex3_18.cpp: At global scope: ex3_18.cpp:27: ISO C++ forbids declaration of `system' with no type
ex3_18.cpp:27: `int system' redeclared as different kind of symbol K:/Eric/Dev-Cpp/include/stdlib.h:373: previous declaration of `int system(const char*)' ex3_18.cpp:27: invalid conversion from `const char*' to `int' ex3_18.cpp:28: parse error before `return'
make.exe: *** [ex3_18.o] Error 1
Execution terminated
I notice that it is moaning about component, which is being passed in to
the
function as an argument, I didnt think I needed to declare component
first,
as I have already done so in the function prototype, like I say this one
has
confused me
See above.
HTH,
--ag
--
Artie Gold -- Austin, Texas
cin >> x >> y;
Thanks :) You can define a function within a function or indeed main(), so remove
from ^^^^^ can't
Ahhh I did wonder if Allan might have meant can't, as it was already
defined in main
I forgot that it is not allowed to define a function within a function, and
that main is itself a function
cheers guys
Rich See above. HTH, --ag
-- Artie Gold -- Austin, Texas
"Artie Gold" <ar*******@austin.rr.com> wrote in message
news:3F**************@austin.rr.com... Allan Bruce wrote: "Rich" <RE**************@yahoo.co.uk> wrote in message news:bf**********@pheidippides.axion.bt.co.uk...
Hi all
I am using DEVCPP 4.9.8.1 which uses MingW32 GCC 3.2 compiler
I am trying to compile this program, but without success, I am sure the compiler is set up ok, as I can compile and run hello.cpp fine
here is the listing please can someone tell what I am doing wrong please
#include <iostream> #include <cstdlib>
using namespace std;
int integerPower ( int, int ) ;
int main( void ) { int x, y ;
cout << "First enter the base number, folowed by the component: " << endl
; cin >> x, y ; cin >> x >> y;
cout << integerPower ( x, y ) << endl ;
You can define a function within a function or indeed main(), so remove
from ^^^^^ can't
here
int integerPower ( int base, int component ) { int ans = base ; for ( i = component; i >=1; --i ) { ans *= base ; }
return ans; }
to here, and then place it at the end of the file Allan system("PAUSE"); return 0; }
and here is the compile log
Compiler: Default compiler Building Makefile: "M:\C++\How To Program\CH03\Ex3_18\Makefile.win" Executing make... make.exe -f "M:\C++\How To Program\CH03\Ex3_18\Makefile.win" all g++.exe -c ex3_18.cpp -o
_18.o -I"K:/Eric/Dev-Cpp/include/c++" -I"K:/Eric/Dev-Cpp/include/c++/ming
2" -I"K:/Eric/Dev-Cpp/include/c++/backward" -I"K:/Eric/Dev-Cpp/include"ex3_18.cpp: In function `int main()': ex3_18.cpp:18: parse error before `{' token
ex3_18.cpp:20: `component' undeclared (first use this function) ex3_18.cpp:20: (Each undeclared identifier is reported only once for
each function it appears in.) ex3_18.cpp:22: `ans' undeclared (first use this function) ex3_18.cpp:22: `base' undeclared (first use this function)
ex3_18.cpp: At global scope: ex3_18.cpp:27: ISO C++ forbids declaration of `system' with no type
ex3_18.cpp:27: `int system' redeclared as different kind of symbol K:/Eric/Dev-Cpp/include/stdlib.h:373: previous declaration of `int system(const char*)' ex3_18.cpp:27: invalid conversion from `const char*' to `int' ex3_18.cpp:28: parse error before `return'
make.exe: *** [ex3_18.o] Error 1
Execution terminated
I notice that it is moaning about component, which is being passed in to
the
function as an argument, I didnt think I needed to declare component
first,
as I have already done so in the function prototype, like I say this one
has
confused me
See above. HTH, --ag
-- Artie Gold -- Austin, Texas
Er, yup thats what I meant ;-)
Allan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: CMEDIA_SOUND |
last post by:
I have a peculiar problem,
I have a tabpage with a label control on it. When i set a background
image to the tabpage and drag the label around it has paint issues in
that it is slow, granted the...
|
by: William.Zhang |
last post by:
the following code:
template <class T>
class test{
typedef T::XXX x;
};
int main(){
return 0;
}
|
by: Klaas |
last post by:
I want the backgrond of my whole page in gradient.
In the source tab I have:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
|
by: ancelotp |
last post by:
hi,
i'm new to sql
i'd appretiate if someone would helpme out with this doudt i have
CODE:
CREATE TABLE entry (
uno int(6) NOT NULL auto_increment,
fname varchar(30) NOT NULL,
sname...
|
by: erotikaboi |
last post by:
Guys, Firstly let me say I am a photographer so if you can offer me a solution I will really appreciate it in simple english not techiespeak as I wont understand it. Thanks.
Ok, I am using Access...
|
by: H0kage |
last post by:
Hello everyone got an assignment for college where i cant find the way to make
JDeveloper to understand where the words are separated.This What
The Assignment Asks.Any Tip or example to help me...
|
by: Jim Florence |
last post by:
Hi,
I've just add a couple of dropdowns to my ASP form, set up a
sqldatasource and bound to the dropdown and it all works great.
I want the first item of the dropdown to be blank soa fter...
|
by: lalou89 |
last post by:
Develop a simple text editor program. The program will show the user a menu of choices and will act according to his choice. Use functional decomposition to break the system into small functions that...
|
by: Sakalicek |
last post by:
Hello all,
I have serious problem and have no idea how to solve it, of course :)
I have Web Service which has master page. This side is the client side. On master page there are some submit...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |