Thread: file location problem

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    file location problem

    I am having a problem with loading files in different location on the harddrive. This is my code for finding the file but it doesnt work
    Code:
    int main()
    {
        char file[250] = "C:\\Documents of Settings\\Raigne\\Shared\\test.mp3";
        wsprintf(file, TEXT("play \"%s\" type mpegvideo alias TempFile"), file );
        printf("%s", file);
        mciSendString(TEXT(file), NULL, 0, NULL);
        system("pause");
    }
    it prints play like 5 times then the type mpeg. it doesnt ever put in the file name. I dont know how to do this, please help

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    You need another variable to hold the command.
    Code:
    int main()
    {
        char file[] = "C:\\Documents of Settings\\Raigne\\Shared\\test.mp3";
        char command[250];
    
        wsprintf(command, TEXT("play \"%s\" type mpegvideo alias TempFile"), file );
        printf("%s", command);
        mciSendString(TEXT(command), NULL, 0, NULL);
        system("pause");
    }

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    if you are using TEXT macro - are yuo compiling for UNICODE?
    In this case you not complient enogh...
    Should be TCHAR not char, for example...

    You should revise your code, currently it is good only for non-UNICODE version, in this case there is no need to use TEXT macro at all
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    ah, I see. is wsprintf even a C++ function or is it C?

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    both can use it (but C++ has some other ways to manipulate strings)
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. read from file problem
    By Martin Kovac in forum C Programming
    Replies: 1
    Last Post: 04-13-2009, 08:33 AM
  2. Subtle(?) File I/O Problem
    By cecomp64 in forum C Programming
    Replies: 9
    Last Post: 07-16-2008, 11:39 AM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  5. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM