473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

INI files

I was trying to learn how the INI files work in C++, I am new to it.

I have found a code at http://www.codeproject.com/cpp/cinifile.asp

I manage to read a value as STRING.

Now, I want to turn it into an integer but I cannot. If it was a CHAR I
would use atoi isnt it? But what shall I do now?

Ferhat
Jul 22 '05 #1
4 4558
"Jazzhouse" writes:
I was trying to learn how the INI files work in C++, I am new to it.

I have found a code at http://www.codeproject.com/cpp/cinifile.asp

I manage to read a value as STRING.

Now, I want to turn it into an integer but I cannot. If it was a CHAR I
would use atoi isnt it? But what shall I do now?


atoi() will do what you want. Look at the declaration more closely, it is
char*n - not simply char - which is another word for C style strings.
Jul 22 '05 #2
Jazzhouse wrote:
I was trying to learn how the INI files work in C++, I am new to it.

I have found a code at http://www.codeproject.com/cpp/cinifile.asp

I manage to read a value as STRING.

Now, I want to turn it into an integer but I cannot. If it was a CHAR I
would use atoi isnt it? But what shall I do now?

Ferhat


Aliter:

Look into stringstreams in C++ . They are much more cleaner.

Eg:

int GetInt(const std::string & value) {
std::istringstream is(value);
int a;
is >> a;
return a;

}

--
Karthik.
http://akktech.blogspot.com .
Jul 22 '05 #3
Jazzhouse wrote:
I was trying to learn how the INI files work in C++, I am new to it.

I have found a code at http://www.codeproject.com/cpp/cinifile.asp

I manage to read a value as STRING.

Now, I want to turn it into an integer but I cannot. If it was a CHAR I
would use atoi isnt it? But what shall I do now?

Ferhat

int value atoi(str.c_str());

should do :)
Jul 22 '05 #4
Jazzhouse wrote:
I was trying to learn how the INI files work in C++, I am new to it.

<snip>

Looks a little nicer than the Windows API for INI files. I wonder if
whoever wrote this:
- hadn't discovered the Windows API functions for this
- wanted a nicer, OO interface
- wanted a cross-platform solution

Though I would have made naming the file and loading it the same
operation, and probably put it in the constructor.

I developed a thing called Configur8, which is a file format similar to
INI but with the ability to include stuff. I got as far as mostly
coding it up (well, enough for my purposes at the mo) in C, C++ and F90.
But it's a read-only interface at the moment....

Stewart.
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.