Results 1 to 23 of 23

Thread: whats wrong with this? the code? my computer?

  1. #1

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Question

    i just got a new computer about 1 mouth ago. and ill ive been doing is vb. but i wanted to make a small media player, i tryed it and it didnt work. well only had 3 mouths worth off c++. for the hell of it i made hello world. but it dosent work. whats wrong with it?

    #include <iostream.h>
    intmain()
    {
    cout<< "hello world/n";
    return 0;
    }

    i dont c any thing worng. do u?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try:
    Code:
    #include <iostream.h>
    
    int main() {
        cout << "Hello World\n";
        return 0;
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Unhappy thx but. . .

    it dosent work. it gives me two errors LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 and Debug/h.exe : fatal error LNK1120: 1 unresolved externals. whats wrong???

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You need to make sure that your project type is Win32 Console Application rather than Win32 Application.

    You're going to have to make a new project.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Talking brb

    have 2 pick up my sis.

  6. #6

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Talking thx

    i hate when i do that. but the other code didnt work before and im sure i had win32 Console App on.
    do u know how 2 declare winmm.dll i cannt figer it out.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    #include <mmsystem.h>

    And add "winmm.lib" to the list of libraries under Project Settings->Linker
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    back

    back

  9. #9

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    error in mmsystem.h

    when i run it with out any extra code but the declareing of the mmcontrol it gives me errors, in mmsystem.h.
    c:\program files\microsoft visual studio\vc98\include\mmsystem.h(113) : error C2146: syntax error : missing ';' before identifier 'MMVERSION'

    c:\program files\microsoft visual studio\vc98\include\mmsystem.h(113) : fatal error C1004: unexpected end of file found

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Did you include <windows.h> before <mmsystem.h> ?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Talking o no

    no i didnt, thx. this is my 1st time doing something like this.

  12. #12

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Talking thx

    thx for helping me!!!

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    No problem.

    Don't worry about errors and stuff like that, it's all part of the learning process. I've been through it as have pretty much every one else. There's no way round it, but it does get easier as you go on
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  14. #14

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    y?

    y dosent it know lpszOpenFlags???

  15. #15
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Context?

    What function are you trying to use?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  16. #16

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    now. . .

    to open but soon to play, stop and close. i got it from the msdn library.

  17. #17

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Talking o

    do u mean i should put something to tell the program what lpszOpenFlags means? like a file name?

  18. #18
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    What function are you trying to use?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  19. #19

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Post open

    right now im just trying to open a file. i found this code:

    MCIERROR mciSendCommand(MCIDEVICEID wDeviceID, MCI_OPEN, DWORD dwFlags, (DWORD) (LPMCI_OPEN_PARMS) lpOpen);

    wsprintf(lpstrCommand, "open %s %s %s", lpszDevice, lpszOpenFlags, lpszFlags);

    they both dont work, but the MSDN libery says it should.

  20. #20
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Did you use:
    Code:
    TCHAR lpstrCommand[256];
    
    wsprintf(lpstrCommand, "open %s %s %s", lpszDevice, lpszOpenFlags, lpszFlags);
    You need to have a properly-allocated buffer.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  21. #21

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Question if state ment not working

    i made a menu to do this, and to do the open funtion i put in this code:
    int f;
    cin >> f;
    if (f == 'open');
    cout << endl;
    cout << "What is the file location?/n";
    TCHAR lpstrCommand[256];
    TCHAR lpszDevice[256];
    TCHAR lpszOpenFlags[256];
    TCHAR lpszFlags[256];
    wsprintf(lpstrCommand, "open %s %s %s", lpszDevice, lpszOpenFlags, lpszFlags);

    but it dosent work. not matter what you type it skips a space then quits. so right now i dont know if it works. but it runs.

  22. #22
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    First thing, you need to use a string, since you can't store text in an integer
    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    void main() {
        string sCmd, sDev, sOpenFlags, sFlags;
    	cout << "Command: ";
        cin >> sCmd;
    	if(sCmd == "open") {
    		cout << endl;
    		cout << "Device: ";
    		cin >> sDev;
    		cout << "Open flags: ";
    		cin >> sOpenFlags;
    		cout << "Flags: ";
    		cin >> sFlags;
    
    		sCmd = sCmd + " " + sDev + " " + sOpenFlags + " " + sFlags;
    		cout << "Command == " << sCmd << endl;
    	}
    
    	// So, to get as a character string, use sCmd.c_str()
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  23. #23

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Talking o

    o thx, but i remember doing it without strings before, maybe i just forgot last time i did c++ was 3 mouths ago.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width