PDA

Click to See Complete Forum and Search --> : whats wrong with this? the code? my computer?


nukem996
Feb 1st, 2001, 03:13 PM
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?

parksie
Feb 1st, 2001, 03:30 PM
Try:

#include <iostream.h>

int main() {
cout << "Hello World\n";
return 0;
}

nukem996
Feb 1st, 2001, 03:37 PM
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???

parksie
Feb 1st, 2001, 03:38 PM
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.

nukem996
Feb 1st, 2001, 03:38 PM
have 2 pick up my sis.

nukem996
Feb 1st, 2001, 03:43 PM
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.

parksie
Feb 1st, 2001, 03:47 PM
#include <mmsystem.h>

And add "winmm.lib" to the list of libraries under Project Settings->Linker

nukem996
Feb 1st, 2001, 03:47 PM
back

nukem996
Feb 1st, 2001, 03:56 PM
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

parksie
Feb 1st, 2001, 04:00 PM
Did you include <windows.h> before <mmsystem.h> ?

nukem996
Feb 1st, 2001, 04:05 PM
no i didnt, thx. this is my 1st time doing something like this.

nukem996
Feb 1st, 2001, 04:08 PM
thx for helping me!!!

parksie
Feb 1st, 2001, 04:11 PM
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 :)

nukem996
Feb 1st, 2001, 04:11 PM
y dosent it know lpszOpenFlags???

parksie
Feb 1st, 2001, 04:16 PM
Context? :rolleyes:

What function are you trying to use?

nukem996
Feb 1st, 2001, 04:25 PM
to open but soon to play, stop and close. i got it from the msdn library.

nukem996
Feb 2nd, 2001, 06:27 PM
do u mean i should put something to tell the program what lpszOpenFlags means? like a file name?

parksie
Feb 2nd, 2001, 06:31 PM
What function are you trying to use?

nukem996
Feb 2nd, 2001, 06:37 PM
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.

parksie
Feb 2nd, 2001, 06:42 PM
Did you use:

TCHAR lpstrCommand[256];

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

You need to have a properly-allocated buffer.

nukem996
Feb 2nd, 2001, 07:24 PM
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.

parksie
Feb 3rd, 2001, 05:22 AM
First thing, you need to use a string, since you can't store text in an integer :rolleyes:

#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()
}

nukem996
Feb 3rd, 2001, 03:58 PM
o thx, but i remember doing it without strings before, maybe i just forgot last time i did c++ was 3 mouths ago.