|
5!
|
|
|
|
|
tom groezer wrote: I need a urgent fix and dont want to travel googling.
It doesn't get much faster than Googling so get used to it. If you had a clue, you'd have had your answer before you could post here.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I'm not quite sure what you've done to annoy CPallini... but he has my trust, so I assume you deserve the long flamewar above this post.
But *I'm* in a good mood...
I would not use the sscanf function at all for this.
One, the tabs / spaces are delimiters. In which case, read a line of text in, then use your favourite string classes Find function to get the next whitespace. Then parse the next up to that point. Delete the text you've parsed, and repeat.
OK, once you've broken the long line into stringlets, then you can use sscanf if you like!
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
I love you, man (expecially with the warrior outfit).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: expecially with the warrior outfit
Since he moved to Sweden, does that involve a big helmet with horns? And yes, I know the Vikings didn't actually wear those but they're cool anyhow.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I think you missed something [^]...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Guess so! I don't usually check the profiles of people I'm familiar with. Guess we'd better send the word out that a raiding party is on the way.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
After your tirade to other professionals here, you surely do not deserve any help.
tom groezer wrote: I need to parse a file...
I'm using sscanf function.
Which means you are using the wrong tool for the job. fscanf() would be used to parse the file, while sscanf() would be used to parse a string read from the file. There is a subtle but big difference. Learn that difference and you'll save yourself many bouts with foot-in-mouth disease.
tom groezer wrote: How do I ensure that I skip the spaces and tabs which could be in randon number.
Is it really that hard to find something like:
char *str = "I really\tdo \t not deserve any\t help";
char s1[8], s2[8], s3[8], s4[8], s5[8], s6[8], s7[8];
sscanf(str, "%s %s %s %s %s %s %s", s1, s2, s3, s4, s5, s6, s7);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I am writing a adler32 code to compute the adler32 checksum of a string.
On the net I came across various sample codes:
I did not understand some code entirely as <b>it has additional code</b> marked in bold below apart from the basic implementation of the adler32 logic.
I did not understand the addional part as to what is is doing.
Can anybody experienced with adler32 give some hint on it?
The various sample codes are:
//---------------------------------------------------------------------
// WIKI
I understood this code as its the basic implementation of the adler32 logic.
So no doubts in this.
/* Loop over each byte of data, in order */
for (size_t index = 0; index < blen; ++index)
{
a = (a + buff[index]) % BASE;
b = (b + a) % BASE;
}
wweak_cs = (b << 16) | a;
//---------------------------------------------------------------------
// RSYNC
I did not understand some code marked in bold below.
{
#define CHAR_OFFSET 0
char *buf = buff;
int len = blen;
int index = 0;
UINT32 s1, s2;
s1 = s2 = 0;
for (index = 0; index < (len-4); index+=4)
{
s2 += 4*(s1 + buf[index]) + 3*buf[index+1] + 2*buf[index+2] + buf[index+3] + 10*CHAR_OFFSET;
s1 += (buf[index+0] + buf[index+1] + buf[index+2] + buf[index+3] + 4*CHAR_OFFSET);
}
for (; index < len; index++)
{
s1 += (buf[index]+CHAR_OFFSET); s2 += s1;
}
rweak_cs = (s1 & 0xffff) + (s2 << 16);
weak_cs = rweak_cs;
}
//---------------------------------------------------------------------
// sharpdevelop
I did not understand some code marked in bold below.
{
char *buf = buff;
int len = blen;
sweak_cs = 1;
int s1 = sweak_cs & 0xFFFF;
int s2 = sweak_cs >> 16 & 0xFFFF;
int index =0;
while (len > 0)
{
int n = 3800;
if (n > len)
{
n = len;
}
len -= n;
while (--n >= 0)
{
s1 = s1 + (int)(buf[index++] & 0xFF);
s2 = s2 + s1;
}
s1 %= BASE;
s2 %= BASE;
}
sweak_cs = (s2 << 16) | s1;
weak_cs = sweak_cs;
}
//---------------------------------------------------------------------
//altivec
I did not understand some code marked in bold below.
{
#define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
# define MOD(a) a %= BASE
char *buf = buff;
int len = blen;
aweak_cs = 1;
unsigned long s1 = aweak_cs & 0xffff;
unsigned long s2 = (aweak_cs >> 16) & 0xffff;
int k;
while (len > 0)
{
k = len < NMAX ? (int)len : NMAX;
len -= k;
while (k >= 16)
{
DO16(buf);
buf += 16;
k -= 16;
}
if (k != 0)
{
do
{
s1 += *buf++;
s2 += s1;
} while (--k);
}
MOD(s1);
MOD(s2);
}
aweak_cs = (s2 << 16) | s1;
weak_cs = aweak_cs;
}
Can anybody clear the doubts?
|
|
|
|
|
Why do you need the 'additional code' can you just use the basic algorithm?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Here also Mr Palini is gracing the posts by his immmaculate understanding of software. Trying to highlack things. Boss come on earth else you will thump down.
|
|
|
|
|
tom groezer wrote: Here also Mr Palini is gracing the posts by his immmaculate understanding of software.
Wow, that's actually nice!
Well, of course you missed the point of my post.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I posted this in the XML forum but now this is definitely a code question.
In the following code using wxWidgets I am trying to access a file inside a zip archive. As you see I have the archiveURL variable set and pass that OpenFile() method.
[code]
wxString archiveURL = _("file:/C:/RM-XML.zip#zip:RM-XML/Attacks.xml");
wxFileSystem* fileSystem = new wxFileSystem;
wxFSFile* file = fileSystem->OpenFile(archiveURL);
if (file)
{
wxInputStream* stream = file->GetStream();
wxXmlDocument xmlFile;
xmlFile.Load(*stream);
if(xmlFile.IsOk())
wxMessageBox(_("Did open xml File"));
else
wxMessageBox(_("Did Not open xml File"));
}
[/code]
The issue is with the variable file. It's corrupted or something because the if(file) comes back false and if I try to access it file->GetLocation() I get a delayed crash after about 7 seconds. I'm pretty sure the zip file is okay and I can use Windows explorer to get the file if I copy and paste the archiveURL string (without the #zip: into the search bar. So I'm stumped. Not sure how to proceed in fixing the variable file. Any ideas?
Thanks!
|
|
|
|
|
I notice wxFileSystem has a URLToFileName method - have you tried converting your URL to a filesystem path and opening that rather than the URL? Obviously, the file is NOT opening, as if (file) fails, so (again, obviously) no operations on file can be performed.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
fixed!
the solution lies in the file path
"file:/C:/RM-XML.zip#zip:RM-XML/Attacks.xml" is not correct
"file:C:/RM-XML.zip#zip:RM-XML/Attacks.xml" is correct
Thanks for pointing out the obvious. It worked.
Also adding this line even those I have something similar in the OnInit() under the App class
fileSystem->AddHandler(new wxZipFSHandler);
is a necessary line. Without, it doesn't work. Weird.
|
|
|
|
|
hi,
i have localize my multibyte application.Everything is working fine except tooltips and msflexgrid headers which are showing garbage.is there any trick that i can show them in japanese with keeping project multibyte.
|
|
|
|
|
instead of saking again you should use Unicode. I got no further clue. Or write your own tooltips as i wrote you a time ago.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
actually i think msflexgrid dnt support unicode.so is there anyway to make it support unicode?
|
|
|
|
|
Why do you think so ?
virtual void BeHappy() = 0;
|
|
|
|
|
bcoz other resources showing japanese but only toolbar tooltips and msflexgrid headers are showing japanese. So they are not supportive for unicode.
|
|
|
|
|
Maybe, the headers do hold its titles in TCHAR* ,
that is only char* in a MULTIBYTE-app (no wide character support)
and WCHAR* in a UNICODE-app (wide character supported)
virtual void BeHappy() = 0;
|
|
|
|
|
i found that ms hierarichal data grid is unicode so now my qus is that can it be used to display tabular data like in msflexgrid?
|
|
|
|
|
Hi,
I have a .vbs script to compile c project. When I try to run it under command prompt it display a message "This script must run under CScript".
I tried to search script on Google but can not find.
Please help....
|
|
|
|
|
Try MSDN, I found the answer here[^].
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|