|
i get 6 errors when i do that expression syntax errors and undefined symbol errors
|
|
|
|
|
Please post the code that produces these errors, or if it's the same code you've already shown, please indicate the error and line number.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Colin, I have a feeling you are really hating programming right about now! I didn't test what I did, I just took your code and rearranged it so it made sense. I thought this might help.
#include "conio.h"
#include "stdio.h"
void main()
{
clrscr();
float number;
float number2;
float answer;
printf("Enter a number: ");
scanf("%f",&number );
printf("What percent of %f would you like to find? ", number);
scanf("%f",&number2 );
answer=number*(number2/100.0);
printf("%f% of %f is %f\n",number2,number,answer);
getch():
}
colin21 wrote:
by the way what is the best c++ compiler? i have turbo c++ now and how do you add computer voice to c++ programs?
Before I started using the Visual Studios I used the Bloodshed DevCpp. I think you can get it at www.bloodshed.net It uses the Gnu compiler, which is the same compiler at Linux systems, which most schools have...so if your programs compile in the DevCpp, it should compile for your professor.
About the computer voice. I think at your level perhaps you should forget about doing anything fun in your programs for quite a while, especially voice. If you want your program to make sounds, put \a in your output statements, it'll create a feeble sounding beep.
Good luck!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
I'm using windows sockets in an application. On both the client and server I use WSAEventSelect() to register the events I'm going to handle. My question is when do the FD_READ and FD_WRITE events get triggered in relation to send() and recv()? I'm confused. Any help is appreciated.
Thanks,
Melinda
|
|
|
|
|
See if either of these two links help:
http://tangentsoft.net/wskfaq/intermediate.html#asyncreliable
http://tangentsoft.net/wskfaq/newbie.html#wouldblock
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I recommend Network Programming for Microsoft Windows, Second Edition
by Anthony Jones and Jim Ohmund.
Kuphryn
|
|
|
|
|
I tried with the microsoft IP address, and neither call to gethost.... is successful.......the longPtrHostEnt is 0, and result is 11004 error which means valid address but no data record found..........
try {
HOSTENT* lngPtrHostEnt ;
char* strHostName ;
unsigned long Addr = inet_addr("207.46.197.102");
lngPtrHostEnt = gethostbyaddr((char*)&Addr, 4, AF_INET);
int result = WSAGetLastError();
or
lngPtrHostEnt = gethostbyaddr("207.46.197.102", 4, AF_INET);
int result = WSAGetLastError();
Thanks,
ns
|
|
|
|
|
There's nothing wrong with your code, other than not checking the return value of inet_addr() . 11004 is a valid return value and means the host could not be found. To verify, try pinging that IP address from a command prompt.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks. Didnt get there with ping. I got that number off the web.
I tried the code with my secondary machines IP address, and it indeed gives me a nonzero pointer to the hostent, but then it crashes at the copymemory where I am trying to get the name....
char* strHostName ;
so I did
CString name (lngPtrHostEnt->h_name);
which worked. But why did the copy mem fail?
Thanks,
ns
|
|
|
|
|
Because strHostName is a pointer that has not been assigned any memory. Try:
char *strHostName = new char[64];<br />
CopyMemory(...);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
From My SDI application I want to use the File->Print to print a XML document that my program creates and using File->Print preview to show the preview. How do I do them? Please help.
Thanks.
|
|
|
|
|
|
I have an encryption routine using Crypto API. Everything in my code works fine as long as I don't save the encrypted value to an Oracle Database. The Oracle Database character set does not support some of the character in the character set that Crypto API uses to Encrypt.
Is there a way to change the character set that Crypto API uses or to convert it in C++? The character set that I need is ISO 8859-1 West European 8-bit character set.
Thanks!!
HckygirlOH
|
|
|
|
|
You can either save it to an Oracle BLOB field, which is proper for binary data, or, if you really need to write it to a (var)char2 field, you may encode it as a base64 string.
You can do it on anything you choose - from .bat to .net - A customer
|
|
|
|
|
Hi all,
I'm working on a project where I have a native (unmanaged) DLL that establishes itself as a filter for system-wide (global) mouse processing. The functional bit of code is this:
<br />
extern "C" __declspec(dllexport)<br />
HHOOK Hook(PFN_MOUSE_MOVE_CALLBACK callback)<br />
{<br />
if (!_hooked)<br />
{<br />
_hooked = true;<br />
_mouseMoveCallback = callback;<br />
_hhk = SetWindowsHookEx(WH_MOUSE, SystemMouseProc, _hinstance, 0);<br />
return _hhk;<br />
}<br />
else<br />
return (HHOOK)NULL;<br />
}<br />
The argument is intended to be used in the actual mouse processing as follows:
<br />
LRESULT CALLBACK SystemMouseProc (int code, WPARAM wparam, LPARAM lparam)<br />
{<br />
if (code >= 0)<br />
{<br />
MOUSEHOOKSTRUCT* mouse = (MOUSEHOOKSTRUCT*)lparam;<br />
<br />
if (_mouseMoveCallback != NULL)<br />
_mouseMoveCallback(mouse->pt.x, mouse->pt.y);<br />
<br />
}<br />
return CallNextHookEx(_hhk, code, wparam, lparam);<br />
}<br />
The problem I'm hitting is that because it's a global hook, this DLL is "injected" (to use Microsoft's verbiage) into each process after it's initially installed by my EXE (which happens to be managed code, though I don't think it affects anything). This makes sense and is in fact what I want, EXCEPT for the fact that I want my callback to work when the thread of execution changes.
When the implementation of SystemMouseProc is changed to just dump to a file, everything's great:
<br />
FILE* stream;<br />
if ((stream = fopen("c:\\hook.txt", "a+")) != NULL)<br />
{<br />
fprintf(stream, "x: %d, y: %d\n", mouse->pt.x, mouse->pt.y);<br />
fclose(stream);<br />
}<br />
Heaps of mouse coordinates.
I guess what I'm trying to do is get some shared chunk of memory between all "instances" (is that the right word?) of my DLL so that regardless of the current process it's running in, my desired callback function can always be called. Right now, if the mouse is over any other program than the original caller, _mouseMoveCallback != NULL evaluates to false and nothing happens.
I've considered falling back on the stream method and just connecting a network socket to localhost between the DLL and calling EXE, but that really didn't seem like the best way to go if it could be helped.
Here's all the code for the DLL. TIA if you can help!
-T
<br />
#include "stdafx.h"<br />
#include "stdio.h"
<br />
<br />
LRESULT CALLBACK SystemMouseProc (int code, WPARAM wparam, LPARAM lparam);<br />
<br />
<br />
typedef void (__stdcall* PFN_MOUSE_MOVE_CALLBACK)(int, int);<br />
<br />
<br />
HHOOK _hhk = 0;<br />
HINSTANCE _hinstance = 0;<br />
bool _hooked = false;<br />
PFN_MOUSE_MOVE_CALLBACK _mouseMoveCallback = NULL;<br />
<br />
<br />
BOOL APIENTRY DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)<br />
{<br />
if (ul_reason_for_call == DLL_PROCESS_ATTACH)<br />
{<br />
if (_hinstance == 0)<br />
{<br />
_hinstance = (HINSTANCE)hModule;<br />
FILE* stream;<br />
if ((stream = fopen("c:\\hook.txt", "a+")) != NULL)<br />
{<br />
fprintf(stream, "Process Attached %d\n", (int)_hinstance);<br />
fclose(stream);<br />
}<br />
}<br />
}<br />
return TRUE;<br />
}<br />
<br />
extern "C" __declspec(dllexport)<br />
HHOOK Hook(PFN_MOUSE_MOVE_CALLBACK callback)<br />
{<br />
if (!_hooked)<br />
{<br />
_hooked = true;<br />
_mouseMoveCallback = callback;<br />
_hhk = SetWindowsHookEx(WH_MOUSE, SystemMouseProc, _hinstance, 0);<br />
return _hhk;<br />
}<br />
else<br />
return (HHOOK)NULL;<br />
}<br />
<br />
extern "C" __declspec(dllexport)<br />
void Unhook()<br />
{<br />
if (_hooked)<br />
UnhookWindowsHookEx(_hhk);<br />
<br />
return;<br />
}<br />
<br />
<br />
LRESULT CALLBACK SystemMouseProc (int code, WPARAM wparam, LPARAM lparam)<br />
{<br />
if (code >= 0)<br />
{<br />
MOUSEHOOKSTRUCT* mouse = (MOUSEHOOKSTRUCT*)lparam;<br />
<br />
if (_mouseMoveCallback != NULL)<br />
_mouseMoveCallback(mouse->pt.x, mouse->pt.y);<br />
<br />
}<br />
return CallNextHookEx(_hhk, code, wparam, lparam);<br />
}<br />
|
|
|
|
|
I'm working on a GUI program in Dev-C++, but I keep getting the following compiler errors:
246 music1b.cpp
C:\DEV-C_~1\Include\lvp\gui_bot.h: In function `int WinMain(HINSTANCE__ *, HINSTANCE__ *, CHAR *, int)':
474 c:\dev-c_~1\include\lvp\gui_bot.h
warning: converting NULL to non-pointer type
474 c:\dev-c_~1\include\lvp\gui_bot.h
warning: converting NULL to non-pointer type
(Line 246 is the bottom of the program where I include gui\bot.h)
Is is possible that there's something wrong with my gui_bot.h file? Do I need a fresh copy of it, or could the problem be with my code?
|
|
|
|
|
I don't see an actual error in the messages, just warnings (unless you have warnings set to be treated as errors). Are there no other messages?
- Mike
|
|
|
|
|
Those are the only messages I'm getting, but it's not letting me execute. The linker gives me:
g++: C:\Dev-C++\Borland\BCC55\Lib\PSDK\winmm.lib: linker input file unused since linking not done
but I don't know if that's relevent or not. Any ideas?
|
|
|
|
|
That warning is harmless -- it's just saying that a library was not included since it never got to the link stage.
Sounds like the compilation proceeded normally, but it never created an executable for some reason. Perhaps it's a problem with project settings... I'm not familiar enough with Dev-C++ to really debug any further, sorry
- Mike
|
|
|
|
|
hi..
i am about to write a report on Microsoft CSocket and CAsyncSocket.
I've heard from ppl that CSocket and CAsyncSocket sucks!!!
i would like to request ppl here who have used CSocket and CAsyncSocket to please provide me with COMMENTS and LINKS which can prove that CSocket and CAsyncSocket are not worth using and contains loopholes...
Would you be pls as kind as to gimme some LINKS and COMMENTS on HOW and WHY do CSocket and CAsyncSocket sucks..!
Tks a lot..
With Regards
Joseph R. Thomas
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
|
|
|
|
|
Read the Winsock Programmers FAQ (Google for it). There is a text there about why it's bad.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
I use the GDI+ in VC7 to save an image. It work very well when I want to save as tiff, png and jpeg. But the program fails to do so when I want to save as wmf, exif and emf.
I consult the msdn and find in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/UsingGDIPlus/UsingImageEncodersandDecoders/Retrievingthe.asp
it said that
"The function GetEncoderClsid in the following example receives the Multipurpose Internet Mail Extensions (MIME) type of an encoder and returns the class identifier (CLSID) of that encoder. The MIME types of the encoders built into Microsoft Windows GDI+ are as follows:
image/bmp
image/jpeg
image/gif
image/tiff
image/png"
Thus it seems that we could not save an image as wmf, exif or emf format. But I also find that
http://www.codeproject.com/cs/media/imagconvert.asp?target=conver
In the C#, we could save an image as wmf, exif or emf format with no pains.
Does anyone know how to solve this puzzle? Thanks a lot!
|
|
|
|
|
Maybe VS.NET adds encoders?
Have you tried enumerating the encoders and getting the available list?
Steve S
|
|
|
|
|
Here is the function GetImageCLSID
static int GetImageCLSID(const WCHAR* format, CLSID* pCLSID)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes
ImageCodecInfo* pImageCodecInfo = NULL;
GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure
GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pCLSID = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
}
free(pImageCodecInfo);
return -1; // Failure
}
|
|
|
|
|
Is there a way that i can set/change a control extended style at run time without having to create it again (Create(...),CreateEx(...))?
|
|
|
|
|