|
Where's char ans;?
You need to a good book for C like
"Beginnig C"
From Novice to Professional,
Fourth Edition
Ivor Horton
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I would strongly recommend this book - online tutorials can get you so far, but you really need a book to properly explain not only about the actual language itself, but the way in which to code certain tasks and explain methodologies and paradigms applicable with the language.
Regards,
--Perspx
"A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year." -Andrew Tanenbaum
"Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer." -Fred Brooks
|
|
|
|
|
Hi ya
I need a good class for saving / loading application settings. I have the following demands for how it should be built:
1) It should be able to handle groups of settings (One group for each view in the application)
2) It should maintain the settings in memory.
3) It should provide an open interface, so one can attach any serialization / deserialization logic (registry-, ini-, xml-file, etc.)
4) It should not have a restricting license like GPL or similar
I can find lots of articles about saving to ini-files, registry-files, xml-files, etc. But I haven't found an article that makes the abstraction I want.
Please let me know
modified on Saturday, February 14, 2009 9:51 AM
|
|
|
|
|
Did you think about your question you need to a class for save application settings of your program you need to make it yourself I think you found your answer previous(ini files,xml files and registry) you need to make a class for them then you need to shift your parameters to that class.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I'm not asking for help to invent the wheel, but asking for help to find an article / library that can provide the implemention of the wheel I need.
I rather want to reuse than to remake it myself.
modified on Saturday, February 14, 2009 11:06 AM
|
|
|
|
|
Good idea: develop it and write a good article about.
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]
|
|
|
|
|
Thank you for the encouragement
|
|
|
|
|
Think I have found the main building block, that satisfies most of my needs:
* Can save to the registry
* Can save to an ini-file
* Can save to an xml-file
And it has a reasonable license requirements:
* You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) when your product is released in binary form.
* You are allowed to modify the source code in any way you want except you cannot modify the copyright details at the top of each module.
* If you want to distribute source code with your application, then you are only allowed to distribute versions released by the author. This is to maintain a single distribution point for the source code.
http://www.naughter.com/appsettings.html
All I need now is to create my in-memory configuration-class, and make a thin wrapper around the AppSettings class.
|
|
|
|
|
In cmath or math.h, there are only float/double versions.
|
|
|
|
|
Why do you need it? If your exponent (or base) is real then you have to use anyway the double version, if both base and exponent are integers then, you know, repeated multiplication does the job.
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]
|
|
|
|
|
There's no power function for integers - your best bet is to try something like this:
int ipow(int x, int y)
{
return (int)pow((double)x, (double)y);
}
Doesn't protect against overflow or anything, but does the job for appropriate inputs.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
int main(void)
{
const char *buf = "PICK ANY TWO: 10 2 F F";
string name;
ostringstream oss;
istringstream iss(buf);
iss.get(*oss.rdbuf(), ':');
name = oss.str();
return 0;
}
modified on Saturday, February 14, 2009 8:53 AM
|
|
|
|
|
Depends what it's meant to do - if it's meant to display a message on the screen, there are plenty of flaws...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Given the string "PICK ANY TWO: 10 2 F F",
get the token before ':', it's "PICK ANY TWO".
|
|
|
|
|
I'd probably do this:
int main(void)
{
const std::string s("PICK ANY TWO: 10 2 F F");
const string name(s.substr(0, s.find(":"));
return 0;
}
Little bit simpler...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Sure
But when I want to parse the string to 5 parts, as
PICK ANY TWO
10
2
F
F
use stringstream seems more consistent,
I'm not sure if there is any simpler version.
C can do this in a very clear way, can C++:
char name[41] = {0};
int m,n;
char c,d;
int i = sscanf_s(buf, "%[^:]%*c%d %d %c %c",name, _countof(name), &m, &n, &c, 1, &d, 1);
Thanks.
|
|
|
|
|
You could use the std::tr1::regex [^] class (that's in from VC2008, I believe). Probably not as simple as sscanf for your case (although I wasn't aware sscanf would parse pseudo-character classes like the [^:] - there's me learnt something new today!).
You're on the cusp of needing something more complex than scanf, for which I guess regex would be as easy as anything else.
Anywhere - here's a regex equivalent for your code (the smiley is a colon followed by an open bracket:
#include <regex>
#include <iostream>
#include <string>
int main(void)
{
std::tr1::regex re("^([^:]*):"
"(\\d+)\\s+(\\d+)\\s+"
"(\\S)\\s+(\\S)$");
std::string s("PICK ANY TWO:10 2 F F");
std::tr1::smatch matches;
if (boost::regex_match(s, matches, re))
{
std::string name = matches[1];
int m = atol(matches.str(2).c_str());
int n = atol(matches.str(3).c_str());
char c = matches.str(4)[0];
char d = matches.str(5)[0];
}
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
How can I create a Hidden Directory?
|
|
|
|
|
Call CreateDirectory() to create the directory, then SetFileAttributes() with FILE_ATTRIBUTE_HIDDEN to hide it.
|
|
|
|
|
yes I know! there is a lot of the same question here in www.codeproject.com. But I need a standard API or something to detect the connectivity.
Thank you masters!
|
|
|
|
|
You can use InternetGetConnectedState() by including wininet.h and using the following snippet:
#pragma comment(lib,"wininet.lib")
if (InternetGetConnectedState(INTERNET_CONNECTION_LAN | INTERNET_CONNECTION_MODEM,0) == FALSE)
{
}
else
{
}
Cheers!
|
|
|
|
|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Check out the IsNetworkAlive API
«_Superman_»
|
|
|
|
|
|
complate update in : 2009/02/20
see you later...!
|
|
|
|