#include %26lt;iostream%26gt;
#include %26lt;iomanip%26gt;
using namespace std;
int main ()
{
int i,k,n=1,m;
cout%26lt;%26lt;"Enter height"%26lt;%26lt;setw(11)%26lt;%26lt;":";
cin%26gt;%26gt;n;
for(m=0; m%26lt;2; m++)
{
for(i=1; i%26lt;=n; i++)
{
if(m==0)
{
for(k=1; k%26lt;=n-1; k++)
{
cout%26lt;%26lt;"";
}
for(k=1; k%26lt;=2*i; k++)
{
cout%26lt;%26lt;"^";
}
}
if(m==1)
{
for(k=1; k%26lt;=i; k++)
{
cout%26lt;%26lt;"";
}
for(k=1; k%26lt;(n-i)*2; k++)
{
cout%26lt;%26lt;"^";
}
}
cout%26lt;%26lt;endl;
}
}
return 0;
}
My errors,
pyr2.obj : error LNK2005: _main already defined in pyramid.obj
Debug/pyramid.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
pyramid.exe - 2 error(s), 0 warning(s)
What is wrong with my C++ code?
It looks like you have a pyr2.cpp and pyramid.cpp file that both define the function main. If you are linking these two files together only one of them can define the function main.
Reply:What's probably the problem is that main is defined as
int main( int argc, char *argv[])
by having main(), it thinks you're trying to redefine it.
Reply:May be you can post your requirements at http://expert.ccietutorial.com/
and let many programmers bid for your project.
You can hire whoever you like.
Do not pay any money afront however.
Reply:You are linking more than one file with a main function in it.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment