|
If you are behind a NAT server, you cannot really get your public IP, except by doing something externally like doing an HTTP connect to download a webpage that simply returns your IP address. For e.g., you could connect to www.whatismyip.com and download the index page, and then parse out the IP address from there.
|
|
|
|
|
I am trying to design a simple program for keeping track of how long people are sitting at a position in a workplace. I would like to represent each person with a small square that looks like a button but can be dragged into and out of position. The button like graphic would have a space for a name and a timer. Is this just a matter of designing a small dialog box or is there some other simple way to do this using icons or cursors ??
thanks
|
|
|
|
|
How to avoid this error and send tcp pack in raw sock mode while sendto() returns SOCK_ERR and WSAEINTR "Interrupted function call." by WSAGetLastError(), although udp packs goes normally. (The code is completely functional and without errors.)
9ine
|
|
|
|
|
I want to write a CStringW string to a wfstream but it doesn't seem to work. Does anyone know how to do this?
my sipet is:
CStringW sRus(_T("ершы шы ф еуые"));
wfstream outFile;
outFile.open("C:\\Junk.txt",ios_base::out);
outFile << sRus << '\n';
outFile.close();
Chris
|
|
|
|
|
|
ChrisLang wrote: I want to write a CStringW string to a wfstream but it doesn't seem to work
The reason why is explained here[^].
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison
Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
You need to open the file in binary mode:
outFile.open("C:\\Junk.txt",ios_base::out | ios_base::binary);
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I have spent hours scouring the net for the answer to this, I do hope somebody could help me here
I'm currently coding an English-Chinese dictionary in C. This dictionary will later be embedded into a PDA with the Hopen OS (Don't worry about this). Anyway, due to this, my final code has to be contained in only 1 file, ie... no .bin or .txt
Basicaly I have included in my code a rather large word list in the following format
#define MAXCHN 100<br />
#define MAXPIN 100<br />
#define MAXENG 200<br />
<br />
typedef struct {<br />
char chn[MAXCHN];<br />
char pin[MAXPIN];<br />
char ove[MAXPIN];<br />
char eng[MAXENG];<br />
}<br />
<br />
Words words[] = <br />
{ <br />
{"°¡","a","¨¡","(interj.) | ah"},<br />
{"°¢","a","¨¡","an initial particle | prefix to names of people"},<br />
{"ºÇ","a","¨¡","(phonetic particle)"}
(please note you may need to alter your code page)
This is some 30000 lines of text.
Now this works all good and proper, but with one drawback, The size. The origional text file is only 1.6Mb, after compilation the file is some 16MB. I realised my error in that each C string is allocated what I earlier defined. So after I compile, some of the shorter lines have a mass of white space after them, increasing the size.
All the text is constant, it will not be changed at all. Basically it is just a waste of space.
Instead of literal strings I tried using pointers i.e
typedef struct {<br />
char *chn;<br />
char *pin;<br />
char *ove;<br />
char *eng;<br />
}
Though this causes buffer overruns during execution. Maybe I overlooked something but I'm pretty sure this isn't the way to go.
Any help, advice or even a head banging would be greatly appreciated. Thankyou.
|
|
|
|
|
waldermort wrote: Though this causes buffer overruns during execution. Maybe I overlooked something but I'm pretty sure this isn't the way to go.
Well, how do you allocate the different strings ?
'any way, I would try to do this in a 2 passes process; write an application that generate a dictionnary in binary format (hexa, or uuencoded ) , and include that data in your final application, use that data as the dictionnary.
or do something like ( does that work ? ):
typedef struct Word {
char *chn;
char *pin;
char *ove;
char *eng;
}
Word _word[] =
{
{"°¡","a","¨¡","(interj.) | ah"},
{"°¢","a","¨¡","an initial particle | prefix to names of people"},
...
};
now, each string ( chh, pin, ove, eng ) will have the right size.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I didnt exactly get u ? ... The size of exe is issue or memory used by program while it is running is issue ?
If both are issues go for allocating data on heap. Only allocate data for the character required at that time while deleting the previous one. I mean u will have use switches with 30,000(whatever lines of text is) cases.
I hope I have understood ur problem correctly && u have understood the solution.
Best of Luck & Best Regards,
|
|
|
|
|
Thanks for the quick replies.
The memory used while running is no problem, however the size of the exe is.
Creating a pointer for each e.g char *chn; causes the program to crash, as far as I can see it has something to do with determining the string length. This may have something to do with limitations of the SDK I am using.
I think I will try recoding this and using multi dimensional arrays.
My question is, what is the best way to include this much text, while at the same time saving space within the exe?
|
|
|
|
|
If exe size is problem then start allocating data on heap. or the other option is compressing data by using binary data just the way Maximilien mentioned.
|
|
|
|
|
waldermort wrote: Words words[] =
{
{"°¡","a","¨¡","(interj.) | ah"},
{"°¢","a","¨¡","an initial particle | prefix to names of people"},
{"ºÇ","a","¨¡","(phonetic particle)"}
MAXCHN 100
See MAXCHN is 100. And you are storing just a small amount of string ie about 2 or 4 chars in each. Once you do this it will run fine. But each structure will take up 400 bytes.
Now just think about the number of structures you allocate. .
I think this is the problem. Be more careful with this.
waldermort wrote: typedef struct {
char chn[MAXCHN];
char pin[MAXPIN];
char ove[MAXPIN];
char eng[MAXENG];
}
You can restructure it like this...
struct {
char chn[10];
char pin[10];
char ove[10];
char eng[MAXENG];
}
Just an Idea.
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
What ur doing is static array , u need to dynamically allocate
memory .
I can see the problem is the Size of file not the memory usage.
Actually from the Architecure view ur including the data file
in your code file , this is an issue .
Do one thing u can create a structure that also stores the
size of four array
<br />
typedef struct{<br />
int MAXCHN,MAXPIN,MAXENG;<br />
char chn*;<br />
char pin*;<br />
char ove*;<br />
char eng*;<br />
}
Process the data file and change the size of each
individual structure data.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
-- modified at 1:21 Friday 30th December, 2005
|
|
|
|
|
Thanks for the advice guys, you have all been very helpful. I saw the error was in not dynamicaly allocating the arrays.
I have scrubbed the whole struct and instead used a an array of pointers to an array of pointers. char *(*results[MAXSTR])[4] Urgh I hated to say it, sorry, I hate arrays too - give me STL any day of the week. Anyway this method is proving more efficient memory wise also since I don't need to deal with whole strings rather just the pointer.
What I thought earlier were buffer overruns were infact a little bug I had overlooked. when calling textout I had set a static length, if the text was shorter then it didnt matter because the white space at the end of the array was overwriting what was previously drawn. When dynamicaly allocating this was causing problems. It'll teach me to clear the canvas before drawing.
I have now got the exe (debug) down to 5mb. for some reason I am having the C1001 INTERNAL COMPILE ERROR when trying a release build. I am also thinking about including a huffman algorithm to further reduce some of that ascii.
|
|
|
|
|
when I select an icon in view, I want the icon appearanced changed to indicate that it is selected.I don't know how to resolve this question .
the icon is on the view.
Help me,thank you.
|
|
|
|
|
See here.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I draw some icons into view ,the icon is from a file.I also draw some text in the view . the view inherit from CSrollView.
but the icon can't be output at the end.
thank you .
|
|
|
|
|
Derive from CFormView instead and you'll be able to create a control to display the icon.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi,
I'm a C++ professional programmer with also some experience with Java. I would like to enter in the .NET world but I don't know what would be better for my future projects: Try with Managed C++ or to learn C#? I've downloaded VS2005 and I've read that there is a new specification for managed C++. So, it seems to me that maybe managed C++ basements aren't enough solid and it will be better to take C# way. But, I not sure if it's good idea to abandon my loved C++.
Please, share your opinions with me.
Thanks a lot,
|
|
|
|
|
|
|
If you alreday know C++, VC++ 2005 will be your best choice for writing .NET applications.
|
|
|
|
|
I prefer to learn a new language
inspite to stick to any one for life.
But its good if they are putting up
Managed C++ , it will be worth studying.
Have u got the seminar given in IIM by
Mr.Azim Premgi he says Change is a fundamental
thing in life and if u cannot adopt to change
then u are not going to advance . The faster
u detect a change the more ahead ur in the
race.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
vikas amin wrote: Have u got the seminar given in IIM by
Mr.Azim Premgi he says Change is a fundamental
thing in life and if u cannot adopt to change
then u are not going to advance
Sorry to trouble you again buddy, not every body here live in India and too in near IIM..
but as usaual what ever azim is almost near to reality
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|