|
leppie wrote:
I can assure you those are NOT wide.
These are the ones: ëêéô
Uhm, okay and sorry abt the confusion. I guess the command prompt is simply unable to show those characters by default. The codepage idea sounds good. Good luck. And if you get it to work, write an article for CP
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant S wrote:
And if you get it to work, write an article for CP
I think its rather a bug in XP ë (copied) for example comes up as 235 where by defualt it should be 137 according to the ASCII table.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
One possible way to display unsigned char in printf is to convert it to an int and display the int as a char .
<br />
int x = 240;<br />
printf("%c .. %d\n", x, x);<br />
This will surely be slow for large strings!
Hope this helps you someway!
Rgds,
Nirav
* The world stands aside to let anyone pass who knows where he is going! - David Jordan *
|
|
|
|
|
Hi,
I must use TStream in an application but I don't know which header to use with it.
Thank you for more infos about it
Florian
|
|
|
|
|
Try asking in a Pascal/Delphi forum ;);)
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Arg... ok thanks
|
|
|
|
|
I am in trouble. I am trying hard to send my tcp packet on the network but the packet is not going. I am using this strategy to do it.
Please tell me if I am setiing any fault attributes.
1. create tcp packet using tcp structure.
2. Send the Packet using "Send to" method.
SOCKET s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
struct ipheader *iph = (struct ipheader *) datagram;
struct tcpheader *tcph = (struct tcpheader *) datagram + sizeof (struct ipheader);
struct sockaddr_in sin;
PS_HDR pseudo_header;
sin.sin_addr.s_addr = inet_addr ("192.168.2.64");
iph->ip_hl = 5;
iph->ip_v = 4;
iph->ip_tos = 0;
iph->ip_len = sizeof (struct ipheader) + sizeof (struct tcpheader);
iph->ip_id = 1;
iph->ip_off = 0;
iph->ip_ttl = 255;
iph->ip_p = 6;
iph->ip_sum = 0;
iph->ip_src = inet_addr ("192.168.2.61");
iph->ip_dst = sin.sin_addr.s_addr;
tcph->th_sport = htons (1234);
tcph->th_dport = htons (PORT);
tcph->th_seq = rand();
tcph->th_ack = 0;
tcph->th_x2 = 0;
tcph->th_off = 0;
tcph->th_flags = 2; // SYN
tcph->th_win = htons(65535);
tcph->th_sum = 0;
tcph->th_urp = 0;
// Build the Psuedo Header
pseudo_header.source_address = inet_addr ("192.168.2.61");
pseudo_header.dest_address = sin.sin_addr.s_addr;
pseudo_header.placeholder = 0;
pseudo_header.protocol = IPPROTO_TCP;
pseudo_header.tcp_length = htons(sizeof(tcpheader));
tcph->th_sum = checksum((unsigned short *)&pseudo_header, sizeof(pseudo_header));
iph->ip_sum = checksum((unsigned short *)&iph, sizeof(ipheader));
// ENABLE IPHDRINCL
if (setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&bOpt, sizeof(int)) == SOCKET_ERROR)
{
printf("setsockopt(IP_HDRINCL) failed: %d\n", WSAGetLastError());
return -1;
}
// Send The Packet
if (sendto(s, datagram, sizeof(datagram), 0, (SOCKADDR *)&sin, sizeof(sin)) == SOCKET_ERROR)
{
printf("sendto() failed: %d\n", WSAGetLastError());
return -1;
}
printf("message sent");
//The code is executing perfectly but the packet does not reach its destination.
//plz help me
Reply me soon
|
|
|
|
|
How do you know the packet does not reach its destination? Maybe it does but the server ignores it or misinterprets the packet as junk.
You implemented datagram. Why?
socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
Kuphryn
|
|
|
|
|
MR kuphryn Firstly I know it because I have a network traffic sniffer running on the detinaion of the program so when packet will reach it will show it.
Second I am not using the datagram socket sock_dgram but creating the tcp packet
socket(AF_INET, SOCK_RAW, IPPROTO_RAW)
IP.PROTOCOL =IPPROTO_TCP
using raw socket please if you can help me by any reference any helping material, code , or anything please do me a favour.
Reply me soon
|
|
|
|
|
According to the rules of C++, a constructor for a class taking a single parameter, could be used to implicitly convert the value of the constructor's parameter type to a value of the constructor's class type.
That means, I ought to be able to convert an "int" value, to a "Number" value. That is not happening. Can anybody see why?
Thanks!
====================================
class Acct;
class Number
{
public:
Number(int i=0) : n(i) {}
Number(const Acct& ac) : acct(ac) {}
void print(Number nbr) { cout<< " Nbr: " << nbr <<endl; }
private:
Acct acct;
int n;
};
----------------------------------------------
int main()
{
Number num;
num.print(99);
return 0;
}
========================
Because it's an "int" I'm printing (as a result of the conversion), I should be able to use the regular standard I/O operators to output the result. The compiler doesn't believe so, and is complaining about that too.
William
Fortes in fide et opere!
|
|
|
|
|
William,
The conversion from int to Number is legitimate in C++, and my VC++ 6.0 compiles it fine. But the print function wont compile, since you are printing a 'Number' and not an int.The compiler has no idea about printing the Number type.To do this you need to overload the insertion operator "<<".
~ Vimal
|
|
|
|
|
Thanks Vimal.
You make a lot of sense and you are correct. However, I had done just what you recommended before posting the note, and everything did work for me.
But when examined, overloading the stream insertion operator "<<" didn't looked like it bought me anything, because I could have obtained the same result if I had not used constructor conversion and had done things the regular way, using an "int" instead for my print() parameter.
I figured as part of the ctor conversion technique, one of the benefits I would obtain, would be NOT having to overload the "<<" operator. Secondly (and this is the part that made me refused to give up), I thought somebody might know of a way (that I didn't) to make what I was trying to achieve, work.
I thank you for your response because it tells me what I was dreaming of doing, will just not work.
Thanks again!
William
Fortes in fide et opere!
|
|
|
|
|
Try changing the print to take a reference:
void print (Number &nbr)
|
|
|
|
|
Friends, i am doing something like:
using namespace std;
hash_set<string> myhashstring;
myhashstring.insert("USA");
As such program is giving me error that:
(38): error C2440: 'type cast' : cannot convert from 'const std::string' to 'size_t'
But if i use "set" instead of "hash_set" the program works normally. Any one guess whats the problem ???
|
|
|
|
|
hash_set is a container. In your code, you did not include the correct template parameters.
http://www.sgi.com/tech/stl/hash_set.html
Kuphryn
|
|
|
|
|
I try to make a CComboBox dynamically which have owner draw.
first, I tried it myself.
It compiled ok, but "Unhandled Access Violation" when execute.
So, I find exercises about ComboBox which have owner draw in CodeProject and Codeguru.
Though So many exercies are, they are not dynamically, but static in dialog
How can I Create CComboBox dynamically which have owner draw?
to be Ace.
|
|
|
|
|
Kindly tell what is a #pragma and why is it a must to use it at some places
Gaurav Gumber
|
|
|
|
|
#pragma gives commands to the compiler. The ones I commonly use are pack to change how struct members are arranged in memory, and comment(lib) to make the linker use a particular import LIB file.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
I would like to achive the following:
91.26464 --> 91.26 (2 digits after the floating point at most)
91.20464 --> 91.2 (because of the 0 at the second position)
91.00464 --> 91 (first 2 digits sfter the floating point are 00)
I tried to use setpresicion and setiosflags but it seems I don't know how to get these results.
-----------------------
Go USA Go
|
|
|
|
|
I have a vexing problem related to CListCtrls and in-place edit.
Very standard stuff here, the CListCtrl is on CPropertyPage.
Inplace editing is called for 4 SubItems/Columns and works perfectly however when
SubItems greater than 0 are dblClicked (i.e list.EditLabel() & OnBeginLabelEdit) the ListItem in column 0 becomes blank until editing is complete (i.e OnEndLabelEdit) when all is restored and OK.
Somehow the SubClassed EditCtrl Overwrites the list.Item before being repositioned over SubItem?
DWORD dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_CHILDRES
WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | LVS_EDITLABELS ;
DWORD dwEXStyle = LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | WS_EX_CLIENTEDGE;
======OnBeginLabelEdit Handler========
CRect rc;
c_List.GetSubItemRect(iItem, iSubItem, LVIR_LABEL, rc );
HWND hWnd = (HWND)c_List.SendMessage(LVM_GETEDITCONTROL);
ASSERT(hWnd != NULL);
VERIFY(m_SubClassedCEdit.SubclassWindow(hWnd));
ASSERT(::IsWindow(m_SubClassedCEdit.m_hWnd));
m_SubClassedCEdit.m_Rec = rc;
m_SubClassedCEdit.SetWindowText(c_List.GetItemText(iItem, iSubItem));
=========================
It must be obvious but I cannot see it. I have tried Invalidating the item, the list ...?$#
Anyone have a working example of item/subitem in-place edit of CListCtrl?
If there are any kind souls out there - please help
Regards In Advance
Bonnie
|
|
|
|
|
While I was looking at an example of class operations I saw something I never seen before. Where the constructor for class Position is declared there is a “:x(xx),y(yy)” statement and I can’t understand what it is doing. I seems like it is using float x and y as functions, and this even before the “{}”. Please explain this statement, what it does, how it does it, what else strange statements like this you can do and if there is any where I can read more about this?
#include<iostream.h><br />
<br />
class Position {<br />
float x,y;<br />
public:<br />
Position(float xx, float yy=0):x(xx),y(yy) {}<br />
Position operator + (const Position& e) const;<br />
Position operator - (const Position& e) const;<br />
<br />
void Display(void)<br />
{ cout << "(" << x << ", " << y << ")" << endl; }<br />
void Input(void)<br />
{ cout << "enter x och y:"; cin >> y;; }<br />
};<br />
<br />
Position Position::operator + (const Position& e) const<br />
{<br />
Position res = *this;<br />
res.x += e.x;<br />
res.y += e.y;<br />
return (res);<br />
}<br />
<br />
Position Position::operator - (const Position& e) const<br />
{<br />
Position res = *this;<br />
res.x -= e.x;<br />
res.y -= e.y;<br />
return (res);<br />
}
Aidman » over and out
|
|
|
|
|
|
Hi,
I've overide a WM_KEY and WM_GETDLGCODE of an CEdit to know when the user presse "enter" key like this :
UINT CMyEdit::OnGetDlgCode()
{
return DLGC_WANTALLKEYS;
}
void CMyEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar==0x0000000d)
Funtion();
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
this way, i can call Function() when user press "enter"... Unfortunalty, there is a "bip" (sound system) when the "enter" key is pressed...
Does anyone know how to disable this "bip" ??
Thanks yyou veru much
|
|
|
|
|
I am writing a C++ DLL which will be called by Visual Basic for Applications in Excel. Should I be using BOOL vs. bool as the type of arguments passed to/from the DLL. For some reason bool doesn't work ... Both C++'s true and false are interpreted as True in VB. Does anyone know why?
Is bool just a 1-byte character whereas BOOL is like an int? What is Boolean type in VB equivalent to in C++?
|
|
|
|
|
Anton A. Loukine wrote:
Should I be using BOOL vs. bool
BOOL
and tell the VB users to use a Long on their end.
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|