|
You mean you want to read in each line, and for each hex value, prefix it with '0x'. You'll need to read from one file, write to another, and then delete the original, and rename your output file. Doing this in place is awkward because you are changing the size of the file.
Hope that helps a bit.
Steve S
|
|
|
|
|
why using 2 different files ?
we can add bytes into a file without overwrite it. an we can move into the file stream...
TOXCCT >>> GEII power
|
|
|
|
|
Using what functions? Anyway, even if those functions existed, the excessive IO to support such a function would vastly dwarf the extra code to create a new file and rename it.
Also, there are other issues involved. What if the program failed halfway through. Now you have a partially converted file which is totally worthless. This is a major concern for real life applications. Either the operation completes successfully or it fails without damaging the original.
BTW, we are converting 1 binary bytes to 10 ASCII bytes. We are doing a lot more than just inserting two characters.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I'm developing a client server application using MFC. My server should be able to accept multiple connection from clients (50 clients). I have a problem when I connect two clients, either one of the client will be disconnected. What is the cause of the problem. I'm really stuck and need help on solving the problem.
Here is my server code that accept client connection:
UINT thread(LPVOID p)
{
char recv_msg[3];
CSize size;
size.cx=0;
size.cy=30;
int s,loop,flag=0;
int msgcount;
CVCBUILD2000Dlg *dlg=(CVCBUILD2000Dlg*)AfxGetApp()->GetMainWnd();
msgcount=dlg->getcount();
msgcount = 1;
if (msgcount==-1)
loop=0;
if(loop)
{
dlg->msgsock[msgcount]=accept(dlg->sock,(sockaddr*)&(dlg->serv),&(dlg->addlen));
s=1;
AfxBeginThread(thread,0);
dlg->SetForegroundWindow();
dlg->m_list.InsertItem(dlg->count++,"Connected");
dlg->m_list.InsertItem(dlg->count++,inet_ntoa(dlg->serv.sin_addr));
dlg->m_list.Scroll(size);
dlg->m_button.EnableWindow(TRUE);
//while ERROR_SOCKET not true
while (s!=-1)
{
//get the input from connected PDA
s=recv(dlg->msgsock[msgcount],recv_msg,5,0);
dlg->m_Status.SetWindowText("");
dlg->ChkInput(recv_msg[0], recv_msg[1]);
if (recv_msg[0] == 'F')
{
s = -1;
}
dlg->SetForegroundWindow();
dlg->m_list.Scroll(size);
}
dlg->msgsock[msgcount]=NULL;
for (int i=0;i<3;i++)
if (dlg->msgsock[i]!=NULL)
flag=1;
if (flag != 1)
{
dlg->m_button.EnableWindow(FALSE);
//this calls the function ClearWindow
//pass 1 param (msgsock)
dlg->ClearWindow(msgcount);
closesocket(dlg->msgsock[msgcount]);
dlg->m_list.InsertItem(dlg->count++,"Disconnected");
dlg->m_edit.SetWindowText("");
}
}
AfxEndThread(0);
return 0;
}
|
|
|
|
|
I really don't understand your code. I think you have major design issues to deal with. Mixing the socket handling code up with the protocol handling code with the windows handling code seems to me to be a recipe for problems. And a thread per connection is usually inefficient. Consider using either MFC sockets, straightforward sockets with Windows Messages for events, or sockets with Events you can 'WaitForMultipleEvents' on. Also reference some of the server library implementations available here. I have one of my own, but it's not documented yet. Here if you're interested.
Anyway I suspect your problem is that 'msgcount' never seems to be set in the 'dlg'. And there's clearly a bug here,
msgcount=dlg->getcount();
msgcount = 1;
Good luck.
Paul
|
|
|
|
|
Sir,
I am developing an which maps CString as the key and maps to the class.
For that I am using this code.
in Person.h"
CPerson {
private:
int age;
public:
CPerson ();
CPerson (int a){
age = a;
}
}
And in "FileView.cpp"
CMapStringToOb map;
CPerson one ;
//one = new CPreson();
map.SetAt( "Bart", one );
This gives me an error.
Pls help me with a solution .
Regards
|
|
|
|
|
use std::map instead. Then you can do this:
myCoolMap["Bart"] = one;
I suspect the problem though is that your class needs a copy constructor and/or operator = in order for this to work.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Either use the template version of CMap (e.g. CMap<CString, LPCTSTR, CPerson*, CPerson*> ) in afxtempl.h , or derive CPerson from CObject .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
First,how can i choose the particular thread which i want to read since there are more than 13000 thread in this forum? Is that any search engine to perform this task?
Second, in the mulitple document application (MFC)project,is there possible to do all this thing as below:
my main task is plotting the different graph at different window from different array , for example array a[] at window:1,array b[]at window:2.
After i open the new window by click the command at New Window at menu in the mainframe ,is that possible to use the same button which in placed at the cformview ,to plot the graph ? How can place the different code in the same button?The case is like this after i compile and built the project:
There is the button named "plot" at the first window(window:1).
The code in the button "plot" is the function to plot array a[];
Then, i open the new window which is window:2, how can i use the same button to plot the array b[]?
Thank you.
|
|
|
|
|
tcsiong wrote:
First,how can i choose the particular thread which i want to read since there are more than 13000 thread in this forum? Is that any search engine to perform this task?
search comments[^]
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Hello,
I need to embed any number of binary files (i.e. Word, Excel, etc) into my CDocument. These may then be extracted to disk and the executed so that the appropriate program is launched.
I have searched the Internet and found no ideas on how to do this. Any suggestions?
Ted
|
|
|
|
|
Consider basing your document type on COleDocument , then storing your own items using classes derived from CDocItem .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Do they have to be legal ip addresses?
And since an ip address can be represented by a single 32bit number wouldn't rand() work?
Here is one structure that windows uses to store ip addresses you can find it in the MSDN help:
struct in_addr {
union {
struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
struct { u_short s_w1,s_w2; } S_un_w;
u_long S_addr;
} S_un;
};
So the code is simple:
in_addr address;
address.S_addr = rand();
John
|
|
|
|
|
All you have to do is generate a number between 0 and 255, once for each octet.
unsigned char s[16];
sprintf(s, "%u.%u.%u.%u",
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256);
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
if you need it into a bind() call, use ADDR_ANY.
TOXCCT >>> GEII power
|
|
|
|
|
I think I'd want to know why.
Is there a legitimate reason for doing this?
Paul
|
|
|
|
|
hello everybody... using vc6/MFC how can i grab highlighted (selected) text from the current screen? Sorta like firing up a spell checker from the task bar to fetch selected word(s). All helpful suggestions appreciated! Thanks!
tom
|
|
|
|
|
This is from the PushSource filter example for DirectShow:
int cbFileHeader = sizeof(BITMAPFILEHEADER);
// Store the size of the BITMAPINFO
BITMAPFILEHEADER *pBm = (BITMAPFILEHEADER*)m_pFile;
m_cbBitmapInfo = pBm->bfOffBits - cbFileHeader;
I'm not quite sure why "bfOffbits - cbFileHeader" is done.. bfOffbits tells you where the actual picture information starts right? So if you subtracted that offset by the header wouldn't you end up with 0?
|
|
|
|
|
When you set a breakpoint on the m_cbBitmapInfo = pBm->bfOffBits - cbFileHeader statement, what are the values of the three variables? In some test code that I had lying around, the value of bfOffBits was 54, so subtracting 14 from that yielded 40.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Because an image is comprised of the following
a header and then the bitmap info
i.e.
a BITMAPFILEHEADER
a BITMAPINFO
then data in 3 tuples RGB RGB RGB RGB etc (for 24 bit)
So the offset must be the addition of the sizes of the header and the info structure.
Regards,
Axe
|
|
|
|
|
The BITMAPINFO consists of a BITMAPINFOHEADER followed by a number of RGBQUAD structures. bfOffBits tells you where in the image the actual image bits start.
The line is computing how big the BITMAPINFO is - the size of the BITMAPINFOHEADER plus the size of the colour table.
The actual layout of a bitmap file is:BITMAPFILEHEADER BITMAPINFOHEADER - One
RGBQUAD for every colour in the colour table - Bitmap bits
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi, I want to sort the contents of a CObList which contains CString objects. Being more experienced in C rather than C++, I immediately thought that qsort() would be the way to go.
However, I now realise that I don't know how to organise the compare routine, as I assume that it is supplied with POSITION elements, but don't know how to access the array from within the routine to compare the CStrings. Is qsort() the way to go with CObList, or is there a better way ? If qsort() is the way, how do I access the CStrings ? Thanks in advance !
Doug
|
|
|
|
|
See this article.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I have an IP Address in CString format
i need it in the BYTE format below.
//BYTE localIp[] = {127,0,0,1};
could anyone show me how to do this?
Thanks
|
|
|
|
|
CString str("127.0.0.1");
struct in_addr ia;
ia.S_addr = inet_addr(str);
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|