|
This is the first time I write a program after learning C++ for 1 week ago.
I use Dev-C++ and I want my program to do function such as:
Ask person to type two number : 1st number ; 2nd number.
such as: 2 ; 5;
and I want my program to get me the sum : 2 + 3 + 4 + 5 = 14
but I try many times and it always gives me : 2 + 5 = 7
This is my code :
using namespace std;
#include <iostream>
long result(long d , long e)
{
if (d >= 1 , d < e)
{
return (result(d + 1,0));
}
else
return (0);
}
int main()
{
long a,b;
long c;
cout << "1st number : ";
cin >> a;
cout << "2nd number : ";
cin >> b;
c = a + result(a , b) + b;
cout << c;
return 0;
}
Can someone tell what 's wrong with my code, and give me a hint to do it.
Thankz.
|
|
|
|
|
The result() function is incorrect. Try this:
long result(long d , long e)
{
long r = 0;
int i;
if (d <= e)
{
for (i == d, i <= e, i++)
{
r += i;
}
}
return (r);
} Also change this line:
c = a + result(a , b) + b;
to
c = result(a , b);
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Thankz for your reply. This is the first time so.....I will practice more.
By the way thankz for your "fish", hope next time to can show me how to fish.
Yeah!!!
|
|
|
|
|
Can anyone tell me how to output data and recieve from a com port on xp/nt in vs2005 managed C++ ?
I have done Parallel i/o before but only on win 9x and never serial.
Thx...
|
|
|
|
|
Hi,
if you are using .Net 2 then System::IO::Ports::SerialPort should be the way to go. However, i found this new serial port class quite unreliable (in terms of switching RTS) and used therefore recently the one from windows.h.
for example:
HANDLE _ComPort = CreateFile( ptrComName,....); // create a port
and use
WriteFile(_ComPort, ptrTxFrame, pTxFrameLength,&ulBytesWritten, 0);
ReadFile(_ComPort, ptrRxFrame, 256, &ulBytesWritten, NULL);
to read and write, but with this approach you'll always have to pinpoint your buffers.
pin_ptr<unsigned char> ptrTxFrame = &pTxFrame[0];
best regards Tobias
|
|
|
|
|
Thx Bee..
I think that was just what I needed.
I wonder tho, about the reliability.
I don't need rts or dts.. just to have them both stay high.
I am wondering if switching is a problem. Can you elaborate a bit on that part?
If I just set it high and forget it, will it stay?
I am hoping the problem you are talking about is the api not seeing the change state.
So if I set it then it will stay, not wanting to write a watchdog for it.
Thx for the reply..
|
|
|
|
|
Right, maybe it did sound a little negative. The reason for my statement was that my application really depends on a very accurate switching time between Request to Send enabled/disabled. For some reason this switching time differs for each switch, 5-15 ms while using the .Net class. Thus I need a constant switching time, which must be less than 10 ms, i'll sometimes run into trouble. With the windows.h method I have never discovered this problem. It displays all the time a continuous 5 ms switch time on my oscilloscope. Probably there is a way to close out this problem but by the time I faced this problem, it was quite critical to go ahead with my project. Therefore I decided to go for the unmanaged option for the time being.
However apart from this odd behaviour this new class is quite comfortable and very straight forward. I'll maybe give it another try after finishing my project.
best regards Tobias
|
|
|
|
|
Hi
I too have been looking for a way to access the comm ports using managed code. I'm pretty new to Visual C++ so I need a little more information regarding how to setup and access a com port connected to a USB-Serial adapter. My comm port shows up as COM7 in windows. I need baby steps for opening, configuring and sending and receiving data. I only need to send about 5 or 6 chars but can possibly receive 10 or up to 512 chars from the serial device I'm interfacing with. All the code I've come across on the web doesn't seem to work with Visual C++ 2005 expess Edition.
|
|
|
|
|
------ Build started: Project: Project4a, Configuration: Debug Win32 ------
Compiling...
Impl.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(112) : error C2011: 'fd_set' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(54) : see declaration of 'fd_set'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(147) : warning C4005: 'FD_SET' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(88) : see previous definition of 'FD_SET'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(156) : error C2011: 'timeval' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(97) : see declaration of 'timeval'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(212) : error C2011: 'hostent' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(153) : see declaration of 'hostent'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(225) : error C2011: 'netent' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(166) : see declaration of 'netent'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(232) : error C2011: 'servent' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(173) : see declaration of 'servent'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(244) : error C2011: 'protoent' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(185) : see declaration of 'protoent'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(400) : error C2011: 'sockaddr_in' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(321) : see declaration of 'sockaddr_in'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(410) : error C2011: 'WSAData' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(331) : see declaration of 'WSAData'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(470) : warning C4005: 'SO_DONTLINGER' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(411) : see previous definition of 'SO_DONTLINGER'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(527) : warning C4005: 'AF_IPX' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(469) : see previous definition of 'AF_IPX'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(555) : warning C4005: 'AF_MAX' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(488) : see previous definition of 'AF_MAX'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(561) : error C2011: 'sockaddr' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(494) : see declaration of 'sockaddr'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(601) : error C2011: 'sockproto' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(503) : see declaration of 'sockproto'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(640) : error C2011: 'linger' : 'struct' type redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(540) : see declaration of 'linger'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(653) : warning C4005: 'SOMAXCONN' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(553) : see previous definition of 'SOMAXCONN'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(679) : warning C4005: 'FD_READ' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(571) : see previous definition of 'FD_READ'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(682) : warning C4005: 'FD_WRITE' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(572) : see previous definition of 'FD_WRITE'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(685) : warning C4005: 'FD_OOB' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(573) : see previous definition of 'FD_OOB'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(688) : warning C4005: 'FD_ACCEPT' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(574) : see previous definition of 'FD_ACCEPT'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(691) : warning C4005: 'FD_CONNECT' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(575) : see previous definition of 'FD_CONNECT'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(694) : warning C4005: 'FD_CLOSE' : macro redefinition
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(576) : see previous definition of 'FD_CLOSE'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1626) : error C2375: 'accept' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(744) : see declaration of 'accept'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1647) : error C2375: 'bind' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(749) : see declaration of 'bind'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1666) : error C2375: 'closesocket' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(754) : see declaration of 'closesocket'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1685) : error C2375: 'connect' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(756) : see declaration of 'connect'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1706) : error C2375: 'ioctlsocket' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(761) : see declaration of 'ioctlsocket'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1727) : error C2375: 'getpeername' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(766) : see declaration of 'getpeername'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1748) : error C2375: 'getsockname' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(771) : see declaration of 'getsockname'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1771) : error C2375: 'getsockopt' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(776) : see declaration of 'getsockopt'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1792) : error C2375: 'htonl' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(783) : see declaration of 'htonl'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1809) : error C2375: 'htons' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(785) : see declaration of 'htons'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1826) : error C2375: 'inet_addr' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(787) : see declaration of 'inet_addr'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1843) : error C2375: 'inet_ntoa' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(789) : see declaration of 'inet_ntoa'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1861) : error C2375: 'listen' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(791) : see declaration of 'listen'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1879) : error C2375: 'ntohl' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(795) : see declaration of 'ntohl'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1896) : error C2375: 'ntohs' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(797) : see declaration of 'ntohs'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1916) : error C2375: 'recv' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(799) : see declaration of 'recv'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1941) : error C2375: 'recvfrom' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(805) : see declaration of 'recvfrom'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1967) : error C2375: 'select' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(813) : see declaration of 'select'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(1991) : error C2375: 'send' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(820) : see declaration of 'send'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2016) : error C2375: 'sendto' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(826) : see declaration of 'sendto'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2042) : error C2375: 'setsockopt' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(834) : see declaration of 'setsockopt'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2064) : error C2375: 'shutdown' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(841) : see declaration of 'shutdown'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2084) : error C2375: 'socket' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(845) : see declaration of 'socket'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2107) : error C2375: 'gethostbyaddr' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(852) : see declaration of 'gethostbyaddr'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2126) : error C2375: 'gethostbyname' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(857) : see declaration of 'gethostbyname'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2144) : error C2375: 'gethostname' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(859) : see declaration of 'gethostname'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2163) : error C2375: 'getservbyport' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(863) : see declaration of 'getservbyport'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2182) : error C2375: 'getservbyname' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(867) : see declaration of 'getservbyname'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2200) : error C2375: 'getprotobynumber' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(871) : see declaration of 'getprotobynumber'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2217) : error C2375: 'getprotobyname' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(873) : see declaration of 'getprotobyname'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2237) : error C2375: 'WSAStartup' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(877) : see declaration of 'WSAStartup'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2255) : error C2375: 'WSACleanup' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(881) : see declaration of 'WSACleanup'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2272) : error C2375: 'WSASetLastError' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(883) : see declaration of 'WSASetLastError'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2289) : error C2375: 'WSAGetLastError' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(885) : see declaration of 'WSAGetLastError'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2306) : error C2375: 'WSAIsBlocking' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(887) : see declaration of 'WSAIsBlocking'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2323) : error C2375: 'WSAUnhookBlockingHook' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(889) : see declaration of 'WSAUnhookBlockingHook'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2340) : error C2375: 'WSASetBlockingHook' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(891) : see declaration of 'WSASetBlockingHook'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2357) : error C2375: 'WSACancelBlockingCall' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(893) : see declaration of 'WSACancelBlockingCall'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2379) : error C2375: 'WSAAsyncGetServByName' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(895) : see declaration of 'WSAAsyncGetServByName'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2406) : error C2375: 'WSAAsyncGetServByPort' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(903) : see declaration of 'WSAAsyncGetServByPort'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2432) : error C2375: 'WSAAsyncGetProtoByName' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(911) : see declaration of 'WSAAsyncGetProtoByName'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2457) : error C2375: 'WSAAsyncGetProtoByNumber' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(918) : see declaration of 'WSAAsyncGetProtoByNumber'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2482) : error C2375: 'WSAAsyncGetHostByName' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(925) : see declaration of 'WSAAsyncGetHostByName'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2509) : error C2375: 'WSAAsyncGetHostByAddr' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(932) : see declaration of 'WSAAsyncGetHostByAddr'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2532) : error C2375: 'WSACancelAsyncRequest' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(941) : see declaration of 'WSACancelAsyncRequest'
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock2.h(2552) : error C2375: 'WSAAsyncSelect' : redefinition; different linkage
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winsock.h(943) : see declaration of 'WSAAsyncSelect'
c:\documents and settings\ashu\desktop\project4a\project4a\Sockets.h(126) : error C2079: 'SocketListener::tcpAddr' uses undefined struct 'sockaddr_in'
Build log was saved at "file://c:\Documents and Settings\ashu\Desktop\Project4a\Project4a\Debug\BuildLog.htm"
Project4a - 58 error(s), 11 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|
|
Looks like you will need to remove "winsock.h" or "winsock2.h" as an included header.
|
|
|
|
|
hi and a big hello!
i wanna code a new server to control a pc.but with ability to be upgrated in future.does anybody know about plugin?
how can i use it in my program?
|
|
|
|
|
i wanna know how i can use messenger or mail services in my code to send infromation to an id in background or in secret way.
-- modified at 1:10 Saturday 22nd April, 2006
|
|
|
|
|
hi
i'm working on a remote admin project but.and it is a big but, i have a problem with controlling file in remote pc.
i wanna see the whole file && dir as i am see in my pc.i mean visual control!i wanna a code more power than ftp trasnfer.
thanks for ur reply
-- modified at 1:03 Saturday 22nd April, 2006
|
|
|
|
|
Can anyone tell me how do I display the selected Node name of a treeView in a text box.
I have treeView containing Nodes(e.g. strings), When the user clicks on a particular string in the treeView, that string should get displayed into a textBox. What code do I need to write in treeView_NodeMouseClick event.
|
|
|
|
|
Could anyone tell me what I'm doing wrong here:
<code>
// variables defined
private: array<String^>^ m_sAddressList = gcnew array<String^>{"localhost"};
private: int m_nCurrentAddress;
...
// attempting to make a property out of them
public: property array<String^>^ m_psAddressList{
String^ get(){ return array<m_sAddressList>(m_nCurrentAddress);}
}
</code>
I'm getting the following compiler error:
error C3901: 'get': must have return type 'cli::array<Type> ^' c:\documents and settings\john\my documents\programming\visual studio 2005\projects\winbot\winbot\ConnectionOperations.h 53
Any information would be greatly appreciated.
Thanks,
John
|
|
|
|
|
The 'get' must return an array to be consistent with how you've defined the property - e.g., return m_sAddressList. It's not clear what you are attempting to return.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter and VB to C++ converter
Instant J#: VB to J# converter
Clear VB: Cleans up VB.NET code
Clear C#: Cleans up C# code
|
|
|
|
|
Forgive my ingnorance but what is with the '^' chaacter?
The way you are using it is a syntax error in C++.
INTP
“Testing can show the presence of errors, but not their absence.”
Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: Forgive my ingnorance but what is with the '^' chaacter?
The way you are using it is a syntax error in C++.
Hi,
It would be a syntax error in standard c++ but isn't this the (Managed) C++/CLI discussion board? Therefore i would like to point out: "The carat operator (^) (often called a "hat" by C++/CLI folks) indicates that a variable or parameter refers to a reference-type object." Or did i misread your point?
regards Tobias
|
|
|
|
|
2beeOr did i misread your point?
Nope! You told me exactly what I wanted to know. I had a feeling it was something like that, as if C++ did not have enough operators already.
INTP
“Testing can show the presence of errors, but not their absence.”
Edsger Dijkstra
|
|
|
|
|
Hi,
I am trying to write a very simple application that mixes MFC with C++ Managed. I have two questions:
1. Is it possible to build the mixed project with the MFC library statically linked. I get some errors of conflict which I don't get when building with dynamically linked.
2. I want to use .NET functions that ask for System::String^ str. When I supply these functions with CString I get error. I read every where that it suppose to work.
CString str = _T("Works");
CString str2 = _T("Doesn't Work");
String ^ stringEx = gcnew String( str ); // OK
strinEx = str2; // Is not working
Thanks.
-- modified at 4:32 Thursday 20th April, 2006
eladbo
|
|
|
|
|
Hi,
You cannot assign an CString object to a string. Every string assignment in .NET creates a new string on the garbage collector and recycles the old one. There is no global defined assignment operator for this available
You could try to write:
strinEx = gcnew String(str);
This makes no difference to the other assignment.
|
|
|
|
|
Hi,
The answer to the first question is probably that it is impossible to do static linking since the code produced for managed application is not native binary code but MSIL.
For different string conversions check following article:
http://msdn2.microsoft.com/en-us/library/ms235631.aspx
Max
|
|
|
|
|
Thanks for the information
eladbo.
|
|
|
|
|
I'm trying to build a dll with the code in the article linked below for use in an otherwise C# (NET1.1) based project. The article itself only includes the class itself, and not any of the packaging needed to run. I tried creating a managed dll, and then just pasting the class data into the cpp/h files. I quickly ran into problems first with it not finding .net types, and then once I added those I started getting linker errors, and quickly got stuck since I haven't done anything c++ related in a long time. I assume I'm missing at least one include statement, but don't know which one.
The only change I've made to the code linked below was to pull the kernel32 stuff back into the main namespace.
http://www.codeproject.com/managedcpp/howtocomport.asp
the errors I'm getting from the linker at the moment are:
SerialPort error LNK2020: unresolved token (0A000025) _CxxThrowException
SerialPort error LNK2020: unresolved token (0A000027) delete
What I have at the moment is below:
SerialPort.h
#pragma once
using namespace System;
using namespace System::IO;
using namespace System::Runtime::InteropServices;
using namespace std;
#ifndef NULL
#define NULL 0
#endif
namespace SerialPort
{
}
SerialPort.cpp
#include "stdafx.h"
#include "SerialPort.h"
namespace SerialPort
{
}
stdafx.h
#pragma once
#include<new>
#include<iostream>
|
|
|
|
|
If I have a service running set up with Local System account.
I will get the "System variable" PATH value when calling
getenv("TEMP")
When I later run my client, I will get the current users TEMP path with the same call. Since that user as it's own defenition of TEMP
How can I get the "System variable" value for the TEMP variable when running as a "normal" user?
//T
|
|
|
|