file location problem

This is a discussion on file location problem within the C++ Programming forums, part of the General Programming Boards category; I am having a problem with loading files in different location on the harddrive. This is my code for finding ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,468
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,468
    both can use it (but C++ has some other ways to manipulate strings)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 01:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21