0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
This line will not input a value for a:
Code:
cout<<”Enter initial value of a”<<a<<endl;
You will need something similar to this:
Code:
cout << "Enter initial value of a: ";
cin >> a;
if (cin.good)
{
    cout << "The initial value you entered is " << a << endl;
}
else
{
    cout << "You failed to enter an appropriate value" << endl;
}
You should not use conio.h, as it is non-portable. Instead of using getch, you may merely do somehting like this:
Code:
cin.sync ();
cin.get ();
The .h forms of include files were initially provided for backward compatibility. You should use <iostream>. There are a number of similar files. The 'C' type files have been renamed mainly like this: math.h >> cmath; stdlib.h >> cstdlib; etc. The old versions won't deal appropriately with the std namespace.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Now it looks like the thread is getting over heated and more personal than on topic.

I would suggest Resh you see the point of the experts that if you provide as much info as possible they will be able to help you better.

DaWei there is some things that does not happen with people instantly. I also get irritated when I need to edit the posts for the code block and thats natural for anyone new to the forums and I dont complain to them unless they do the same thing.

I would leave upto you gentleman's to make the things steady. After all its your community.
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
As you can see, my last response has no heat. The OP posted work; I pointed out the errors, suggested solutions, and gave the reasons.
0
aVague's Avatar, Join Date: May 2007
Go4Expert Member
all happy , so it' over : )
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by aVague
all happy , so it' over : )
0
Resh's Avatar, Join Date: May 2007
Go4Expert Member
ok thank you DaWei for you help it was helpful i modified the program a lot and it is up and running perfectly now. However i am have another problem with another program i am getting an external error existing


--------------------Configuration: attempt on task 3(3) - Win32 Debug--------------------
Linking...
attempt on task 3(3).obj : error LNK2001: unresolved external symbol "void __cdecl moveto(int,int)" (?moveto@@YAXHH@Z)
attempt on task 3(3).obj : error LNK2001: unresolved external symbol "void __cdecl lineto(int,int)" (?lineto@@YAXHH@Z)
attempt on task 3(3).obj : error LNK2001: unresolved external symbol "void __cdecl setcolor(int)" (?setcolor@@YAXH@Z)
attempt on task 3(3).obj : error LNK2001: unresolved external symbol "void __cdecl closegraph(int)" (?closegraph@@YAXH@Z)
attempt on task 3(3).obj : error LNK2001: unresolved external symbol "void __cdecl initgraph(int *,int *,char *)" (?initgraph@@YAXPAH0PAD@Z)
Debug/attempt on task 3(3).exe : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.

attempt on task 3(3).exe - 6 error(s), 0 warning(s)


Nothing i try seems to get rid of it.
This is not the same program this is another program
0
aVague's Avatar, Join Date: May 2007
Go4Expert Member
...
as I can see here, you 're working with graphics

and as I can assume, argument of those functions are out of range ...

2 moments you need to do:
1) create new topic ( cause its a new programm, and new problem)
2) view us a code of a programm
0
Resh's Avatar, Join Date: May 2007
Go4Expert Member
This the code i am working with below:
When i compile i am getting no errors however when i build i am getting the 6errors i sent before and nothing i try seems to get rid of it.

Code:
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<conio.h>
//#include<cstdlib.h>


#ifndef WINBGI_H
#define WINBGI_H
#include <windows.h>        // Provides the mouse message types
#include <limits.h>         // Provides INT_MAX
#include <sstream>          // Provides std::ostringstream

// The standard Borland 16 colors
#define MAXCOLORS       15
enum colors { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY,
              LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE };
 
// Drawing Functions
void initgraph( int *graphdriver, int *graphmode, char *pathtodriver );
void lineto(int x, int y);
 
// Miscellaneous Functions
void moveto(int x,int y);
void setcolor( int color );
 
// The various graphics drivers
enum graphics_drivers { DETECT, CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514, HERCMONO,
                        ATT400, VGA, PC3270 };
 
// Various modes for each graphics driver
enum graphics_modes { CGAC0, CGAC1, CGAC2, CGAC3, CGAHI, 
                      MCGAC0 = 0, MCGAC1, MCGAC2, MCGAC3, MCGAMED, MCGAHI,
                      EGALO = 0, EGAHI,
                      EGA64LO = 0, EGA64HI,
                      EGAMONOHI = 3,
                      HERCMONOHI = 0,
                      ATT400C0 = 0, ATT400C1, ATT400C2, ATT400C3, ATT400MED, ATT400HI,
                      VGALO = 0, VGAMED, VGAHI,
                      PC3270HI = 0,
                      IBM8514LO = 0, IBM8514HI };
 
// Constants for closegraph
#define CURRENT_WINDOW -1
#define ALL_WINDOWS -2
#define NO_CURRENT_WINDOW -3
 
 
// Window Creation / Graphics Manipulation
void closegraph( int wid=ALL_WINDOWS );
 
				
const int X0=320;
const int Y0=240;
const double PI=3.14159;
const int NUME=30;
const int DENOM=100;
const int NUMBER=7;
const double RAD=3.0;
const double DELTHETA=0.1;
const int SEGS=60;
const int REDUX=3;
const int MIN=1;
 
class cluster
{
public:
            
	void display(int size,int x,int y);
};
 
class tendril
{
public:
            void display(int size,double theta,int x,int y);
};
 
void cluster::display(int size,int x,int y)
{
            if(kbhit())
                        exit(0);
            for(int i=0;i<NUMBER;i++)
            {
                        double theta=i*2*PI/NUMBER;
                        moveto(x,y);
                        tendril t;
                        t.display(size,theta,x,y);
            }
}
void tendril::display(int size,double theta,int x,int y)
{
            for(int j=0;j<size;j++)
            {
                        double chng=rand();
                         if ((chng < NUME) ?-1:1)
  						 {
                            double theta=theta+chng*DELTHETA;
                            double x=x+RAD*sin(theta);
                            double y=y+RAD*cos(theta);
                         }
                        if(size<4)setcolor(RED);
                                    else if(size<13)setcolor(GREEN);
                        else if(size<40)setcolor(LIGHTGREEN);
                        else setcolor(YELLOW);
                        lineto(x,y);
            }
            if(size>MIN)
            {
                        cluster c;
                        int newsize=size/REDUX;
                        c.display(newsize,x,y);
            }
}
void main()
{
            int driver,mode;
            driver=VGA;
            mode=VGAHI;
            initgraph(&driver,&mode,"\\bc45\\bgi");
            rand();
 
            int x=X0,y=Y0;
            int size=SEGS;
            cluster c;
            c.display(size,x,y);
            getch();
            closegraph();

#endif // WINBGI_H
}

Last edited by shabbir; 10May2007 at 21:36.. Reason: Code block
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
What compiler and OS are you using? The code seems to indicate that you are trying to use a Borland library that dates back to before Windows was a protected-mode operating system. That's why I mentioned the non-portability of conio.h. It is not a part of the standard C runtime library. Even if your library (whatever it is) is compatible with modern systems (which I highly doubt), you are obviously missing the library file, itself. Header files only provide declarations. This is all the compiler needs. Library files contain the actual code referred to by those headers. They must exist and be found by the linker.

The missing files are console control commands. All such commands are non-portable. If you absolutely feel you must have them, then you need to get them for whatever particular hardware platform and operating system you have. There are ways to make those for both Windows and *nix platforms, but again, you won't be able to move your code from one kind of machine to another.

You are obviously using C++, because of the sstream inclusion. Again, you should dump the pre-standard headers. The only .h file you should have is windows.h and any .h files you write for yourself.

It is not good to use C-style I/O mixed with C++ streams. Unless you know precisely what you're doing, there is no guarantee of synchronization between the two.

When you post code, put it in code tags. Put [/code] at the bottom of the code, and [code] at the top. HTML pages such as these eat whitespace. The code tags preserve it.
0
aVague's Avatar, Join Date: May 2007
Go4Expert Member
Code:
initgraph(&driver,&mode,"\\bc45\\bgi");
what does it means?