Skip to main content
gamedev.net
🔒 Locked

Problems with errors

Started by demonrealms 3 replies 500+ views
Original Post
demonrealms
demonrealms
Hey, why does this code have a problem? Heres my code:
  
else if(ipt1 == mdir)
	{
		int sec1;
		int sec2;
		int sec3;
		int sec4;
		char dmem[180];
		GetCurrentDirectory(180, dmem);
		GetDiskFreeSpace( dirname, sec1, sec2, sec3, sec4);
		cout << " " <<  dmem << "...." << endl;
		return(main());
	}
  
Here are my error''s
  --------------------Configuration: Sathenzar - Win32 Debug--------------------
Compiling...
Sathenzar.cpp
C:\demonrealms\Sathenzar.cpp(312) : error C2664: ''GetDiskFreeSpaceA'' : cannot convert parameter 2 from ''int'' to ''unsigned long *''
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

Sathenzar.obj - 1 error(s), 0 warning(s)  
And can you please NOT ask me why I''m returning main?? I don''t care about that. I just want to know why the section of code doesn''t work. (Not trying to be rude either) Thanks, Demon Realms Studios
randomZ
randomZ
The function seems to expect unsigned long* instead of int, so you need to change you declarations:


  
unsigned long sec1;
unsigned long sec2;
unsigned long sec3;
unsigned long sec4;


and call it with the adress of the vars:


  
GetDiskFreeSpace( dirname, &sec1, &sec2, &sec3, &sec4);


Hope that helps.



BTW, why are you returning main?


My Wonderful Web Site (C++ SDL OpenGL Game Programming)

I am a signature virus. Please add me to your signature so that I may multiply.
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/
demonrealms
demonrealms
It sill comes up with these errors:

  Sathenzar.cpp
C:\demonrealms\Sathenzar.cpp(312) : error C2664: ''GetDiskFreeSpaceA'' : cannot convert parameter 2 from ''unsigned long'' to ''unsigned long *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

Sathenzar.obj - 1 error(s), 0 warning(s)

And this is my code now:
  else if(ipt1 == mdir)
{
unsigned long sec1;
unsigned long sec2;
unsigned long sec3;
unsigned long sec4;
char dmem[180];
GetCurrentDirectory(180, dmem);
GetDiskFreeSpace( dirname, sec1, sec2, sec3, sec4);
cout << " " << dmem << "...." << endl;
return(main());
}
randomZ
randomZ
Yep, you missed the ''&''s in the function call, which generate the adress of the respective object they''re used on. This makes the argument a pointer.

sec1 is of type unsigned long
&sec1 is of type unsigned long*


My Wonderful Web Site (C++ SDL OpenGL Game Programming)

I am a signature virus. Please add me to your signature so that I may multiply.
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.