Thread: Converting CHAR * to char

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    26

    Converting CHAR * to char

    I nead to convert the CHAR* that I get from the edit control to a char
    Code:
    CHAR *dtext;
    GetWindowText(DRIVE,dtext,1);//get drive letter from EDIT
    char dletter;
    // This is where the conversion should take place
    FSOUND_CD_Play(dletter,1);
    Searching the board answered 100s of my other questions but for this one i cant really find what i'm looking for.
    Thanks
    Last edited by SwiftOutlaw; 11-08-2004 at 07:37 PM. Reason: not enough info

  2. #2
    Registered User cfrost's Avatar
    Join Date
    Apr 2004
    Posts
    119
    ok looks like you want a drive letter so it must be exsiting at index 0 of dtext
    to get it you can simply say:
    dletter=dtext[0];

    Try and tell me if this works
    Software is like sex it is good when it is free

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Well, your code would crash, because you're not allocating memory to that pointer. Second Its only a char, so send a memory adress, instead of declaring a pointer.
    Code:
    char dletter;
    GetWindowText(DRIVE,&dletter,1);//get drive letter from EDIT
    // This is where the conversion should take place
    FSOUND_CD_Play(dletter,1);

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    26

    Thumbs up

    xErath's code worked.
    thanks both of you for helping

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 08-11-2008, 11:02 PM
  2. Obtaining source & destination IP,details of ICMP Header & each of field of it ???
    By cromologic in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-29-2006, 02:49 PM
  3. Replies: 6
    Last Post: 06-30-2005, 08:03 AM
  4. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  5. comparing fields in a text file
    By darfader in forum C Programming
    Replies: 9
    Last Post: 08-22-2003, 08:21 AM