Thread: How to convert from PULARGE_INTEGER to a character string

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    18

    How to convert from PULARGE_INTEGER to a character string

    Hi All,
    How to convert from PULARGE_INTEGER to a character string??

    I need to display a value (free disk space) in a message or textbox.

    Any ideas would be great,
    Thanks,
    Donal

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    _ltoa() converts from a long to char. The fact that it's a pointer shouldn't matter because since you're trying to display free disk space you'll actually be using the value that the pointer points to (in this case the unsigned long).

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    18
    Hi jdinger,
    If i didn't put in the type casting the code won't compile, I'd get this error:
    (91) : error C2664: '_ltoa' : cannot convert parameter 1 from 'union _ULARGE_INTEGER *' to 'long'

    If I do put in the type casting then I get an Access Violation error when the _ltoa() function runs.
    Any Ideas??
    Thanks,
    Donal



    Code:
    	
    PULARGE_INTEGER lpFreeBytesAvailableToCaller, lpTotalNumberOfBytes,lpTotalNumberOfFreeBytes  ;
    char temp[200];
    
    
    case IDACHECK:
    			GetDiskFreeSpaceEx("c:",lpFreeBytesAvailableToCaller, lpTotalNumberOfBytes,lpTotalNumberOfFreeBytes);
    			_ltoa((int)lpTotalNumberOfFreeBytes, temp, 10);
    
    			MessageBox(hwnd, temp, "Free disk Space", MB_OK);
    			return(TRUE);
    			break;

  4. #4
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    That's because you're trying to convert the pointer itself instead of the value that it points to. Use the * (dereferrence) operator to get the value.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  4. How to convert a string to a character array?
    By Aven in forum C++ Programming
    Replies: 4
    Last Post: 04-17-2005, 11:14 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM