Click here to Skip to main content
16,011,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: connecting P2P Pin
Nish Nishant29-Dec-05 10:06
sitebuilderNish Nishant29-Dec-05 10:06 
QuestionDragable buttons Pin
zapper22229-Dec-05 7:56
zapper22229-Dec-05 7:56 
Questionsendto() in raw sock mode gets WSAEINTR err. Pin
9ine29-Dec-05 7:33
9ine29-Dec-05 7:33 
Questionhow to write a unicode string to a text file Pin
ChrisLang29-Dec-05 7:27
ChrisLang29-Dec-05 7:27 
AnswerRe: how to write a unicode string to a text file Pin
Nish Nishant29-Dec-05 8:36
sitebuilderNish Nishant29-Dec-05 8:36 
AnswerRe: how to write a unicode string to a text file Pin
Taka Muraoka29-Dec-05 18:04
Taka Muraoka29-Dec-05 18:04 
AnswerRe: how to write a unicode string to a text file Pin
krmed30-Dec-05 3:57
krmed30-Dec-05 3:57 
QuestionDynamic arrays in C Pin
Waldermort29-Dec-05 4:03
Waldermort29-Dec-05 4:03 
I have spent hours scouring the net for the answer to this, I do hope somebody could help me here Wink | ;)

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.
AnswerRe: Dynamic arrays in C Pin
Maximilien29-Dec-05 5:55
Maximilien29-Dec-05 5:55 
AnswerRe: Dynamic arrays in C Pin
Identity Undisclosed29-Dec-05 6:07
Identity Undisclosed29-Dec-05 6:07 
GeneralRe: Dynamic arrays in C Pin
Waldermort29-Dec-05 6:29
Waldermort29-Dec-05 6:29 
GeneralRe: Dynamic arrays in C Pin
Identity Undisclosed29-Dec-05 18:28
Identity Undisclosed29-Dec-05 18:28 
AnswerRe: Dynamic arrays in C Pin
Owner drawn29-Dec-05 17:05
Owner drawn29-Dec-05 17:05 
AnswerRe: Dynamic arrays in C Pin
vikas amin29-Dec-05 19:05
vikas amin29-Dec-05 19:05 
AnswerRe: Dynamic arrays in C Pin
Waldermort30-Dec-05 1:48
Waldermort30-Dec-05 1:48 
QuestionShade icon on the view (SDI ) Pin
zhonglin.liang29-Dec-05 3:47
zhonglin.liang29-Dec-05 3:47 
AnswerRe: Shade icon on the view (SDI ) Pin
David Crow29-Dec-05 3:50
David Crow29-Dec-05 3:50 
QuestionThe icon in the view can't be printed in SDI,the text is able to print ? Pin
zhonglin.liang29-Dec-05 3:46
zhonglin.liang29-Dec-05 3:46 
AnswerRe: The icon in the view can't be printed in SDI,the text is able to print ? Pin
David Crow29-Dec-05 3:52
David Crow29-Dec-05 3:52 
QuestionAdvice: Managed C++ or C# Pin
fmmanrique29-Dec-05 3:21
fmmanrique29-Dec-05 3:21 
AnswerRe: Advice: Managed C++ or C# Pin
Chris Losinger29-Dec-05 4:42
professionalChris Losinger29-Dec-05 4:42 
AnswerRe: Advice: Managed C++ or C# Pin
Nemanja Trifunovic29-Dec-05 4:46
Nemanja Trifunovic29-Dec-05 4:46 
AnswerRe: Advice: Managed C++ or C# Pin
Nish Nishant29-Dec-05 8:30
sitebuilderNish Nishant29-Dec-05 8:30 
AnswerRe: Advice: Managed C++ or C# Pin
vikas amin29-Dec-05 18:40
vikas amin29-Dec-05 18:40 
GeneralRe: Advice: Managed C++ or C# Pin
ThatsAlok29-Dec-05 21:13
ThatsAlok29-Dec-05 21:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.