#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12

    Program Related to how to open a file from a program...


    Code:
    #include <iostream>
    using namespace std;
    class Complexam
    {
    protected:
    	float rp;
    	float ip;
    public:
    	Complexam()
    	{
    		rp=0.0;
    		ip=0.0;
    	}
    	Complexam( float a, float b);
    	void show();
    	void getdata( Complexam &a);
    	void add( Complexam a, Complexam b, Complexam &c);
    };
    //=============================================
    Complexam::Complexam( float a, float b)
    {
    	rp=a;
    	ip=b;
    }
    //--------------------------------------------
    
    void Complexam::show()
    {
    	char sign;
    	if (ip>=0) sign='+';
    	else sign=' ';
    	cout<<" ( "<<rp<<" "<<sign<<" "<<ip<<" i)";
    }
    //---------------------------------------------
    void Complexam:: getdata (Complexam &a)
    {
    	cout<<"\nEnter real part>";
    	cin>>a.rp;
    	cout<<"\nEnter Imaginary part>";
    	cin>>a.ip;
    	return;
    }
    //---------------------------------------------
    void Complexam:: add( Complexam a, Complexam b, Complexam &c)
    {
    	c.rp=a.rp+ b.rp;
    	c.ip=a.ip+b.ip;
    	return;
    }
    //=============================================
    
    
    
    void main()
    {
    	Complexam a;
    	cout<<"\na=";
    	a.show();
    	Complexam b(3, -5);
    	cout<<"\nb=";
    	b.show();
    	a.getdata( a);
    	cout<<"\nmodified a=";
    	a.show();
    	Complexam c;
    	cout<<"\ndeclared c:"; c.show();
    	a.add(a,b,c);
    	cout<<"\nc=a-b:";
    	c.show();
    	cout<<"\n\n\n\n";
    	return;
    }
    //==============================================
    
    Note: This program works! and i saved this program as Complex2 on my zip disk/
    
    in my other program, i am trying to open this work/read it..so the program would run...
    
    ~~~~~~~~~~~~~~~~~~~~~~~
    #include <iostream>
    #include <G:\complex2.cpp>
    
    using namespace std; 
    
    class complex
    {
    	complex():	Complexam()//call construct of complexam
    	{}
    	complex ( float a, float b) 
    	{ complexam(a,b):}
    	void sub(complex a, complex b, complex &c)
    	{
    		complex nb;
    		nb.rp=b.rp* (-1);
    		nb.ip=b.ip* (-1);
    		complexam:: add(a, nb,c);
    		return;
    	}
    };
    
    void main()
    {
    	complex a;
    	--";
        complex b(3,-5);
    	a.getdata();
    	a.show();
    	complex c;
    	c.add(a,b,c);
    		c.show();
    }
    however, the error is..

    fatal error C1083: Cannot open include file: 'G:\complex2.cpp': No such file or directory....

    hmmmm...........

    *edit: added code tags
    *note: deleted duplicate thread to this
    Last edited by Onslaught; October 6th, 2003 at 09:16 PM.
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,181
    Rep Power
    2222
    Are you sure that you have a G: drive on that computer? And that that file is in that directory?

    Please open Windows Explorer or a DOS prompt and go to that drive and to the root directory on that drive and look to see that a file named complex2.cpp is there.

    ----------------------
    Assume nothing. Suspect everything.
    -- Inspecteur Clouseau
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12
    yea, i have a zip drive which is the G drive and the file is there!!....complex2.cpp in that drive...hmmm

    *shrug* hmmmm..
    Last edited by ringsamh; October 7th, 2003 at 11:03 AM.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12

    Unhappy


    *anyone know what to do in this situation?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    118
    Rep Power
    13
    I believe you need to replace your "<" and ">" with quotation marks when it's not a native header file to your compiler.

    #include <G:\complex2.cpp>

    into

    #include "G:\complex2.cpp"
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12
    i made the change and still it doesn't work~
  12. #7
  13. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,641
    Rep Power
    4247
    er.. have you tried:
    #include "G:\\complex2.cpp"

    Note the doubled backslash
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12
    yea, and still it doesn't work~~ sigh~ program is due Monday~~~
  16. #9
  17. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,181
    Rep Power
    2222
    Why don't you just copy the header file into the same directory as the other source files? Then you only need to have the file name in double quotes and not the path.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12
    u mean as renaming the file?
  20. #11
  21. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,181
    Rep Power
    2222
    Originally posted by ringsamh
    u mean as renaming the file?
    I mean as in opening a DOS window, cd'ing to the directory containing your source files on whichever drive you have them on, and entering the command:
    copy g:\complex2.cpp

    Then change that line in your program to :
    #include "complex2.cpp"
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12
    sounds very comlicated!!! can you explain to me how to cd to the directory in the soruce file! Dos won't let me get access to that drive, although it only allows in Windows...hmmmm
  24. #13
  25. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,641
    Rep Power
    4247
    Looks like we have light at the end of the tunnel. Can you use Windows explorer to copy the file? Odd that Windows can see it, but won't let a dos app see the drive? That could explain why the compiler is not seeing the .h file though.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  26. #14
  27. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,181
    Rep Power
    2222
    Originally posted by ringsamh
    sounds very comlicated!!! can you explain to me how to cd to the directory in the soruce file! Dos won't let me get access to that drive, although it only allows in Windows...hmmmm
    If I were to have told you how to copy a file through the GUI, then it would have taken multiple pages and even a seasoned programmer could not have followed it. That is really complicated stuff. Using the command line is the simple way.

    You cd to a directory with this syntax:
    cd directory_path

    To go to a different drive, the command is simply the drive name:
    g:

    Sorry, I really don't know how much simpler it could be.

    But since you say that you cannot get to that drive, then it sounds like your computer has some serious problems, which could explain why the compiler cannot find that file. I believe you said that's a zip drive. They used to suffer from the Click of Death and I have had zip disks suddenly become unreadable or even write-protected.

    With whatever text editor you use, try to open that file. If you cannot, then zipdisk failure could be your problem.

IMN logo majestic logo threadwatch logo seochat tools logo