473,729 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string class problem

can anyone tell me a solution:
i cannot use the features in standard c++ string classgh i included
the string.h file but still its not working.

Jun 25 '07 #1
22 2609
On Mon, 25 Jun 2007 09:15:45 -0700, mann_mathann wrote:
can anyone tell me a solution:
i cannot use the features in standard c++ string classgh i included the
string.h file but still its not working.
To use the class std::string

#include <string>

Note: string.h contains headers for the standard C (as opposed to C++)
string manipulation routines. If you need these in C++ (and chances are
you don't if you're using std::string) then you should include them via
the header <cstringrathe r than string.h.

--
Lionel B
Jun 25 '07 #2
ma**********@ya hoo.co.in wrote:
can anyone tell me a solution:
i cannot use the features in standard c++ string classgh i included
the string.h file but still its not working.
Because <string.his the C90 header (C++ equivalent is <cstring>). Try
using <string(note the lack of .h) And don't forget the std:: when
using std::string.
Jun 25 '07 #3
ma**********@ya hoo.co.in wrote:
can anyone tell me a solution:
i cannot use the features in standard c++ string classgh i included
the string.h file but still its not working.
Because the file is called <stringnot <string.h>

john
Jun 25 '07 #4
On 2007-06-25 18:36, Lionel B wrote:
On Mon, 25 Jun 2007 09:15:45 -0700, mann_mathann wrote:
>can anyone tell me a solution:
i cannot use the features in standard c++ string classgh i included the
string.h file but still its not working.

To use the class std::string

#include <string>

Note: string.h contains headers for the standard C (as opposed to C++)
string manipulation routines. If you need these in C++ (and chances are
you don't if you're using std::string) then you should include them via
the header <cstringrathe r than string.h.
I'd like to add that none of the C++ standard headers have a .h in them.

--
Erik Wikström
Jun 25 '07 #5
In article <eh************ ****@newsb.teli a.net>, Er***********@t elia.com
says...

[ ... ]
I'd like to add that none of the C++ standard headers have a .h in them.
Sort of true -- the C++ standard does explicitly include the headers
from the C standard that have a '.h' on them.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jun 25 '07 #6
Lionel B wrote:
On Mon, 25 Jun 2007 09:15:45 -0700, mann_mathann wrote:
can anyone tell me a solution:
i cannot use the features in standard c++ string classgh i
included the string.h file but still its not working.

To use the class std::string

#include <string>

Note: string.h contains headers for the standard C (as opposed to
C++) string manipulation routines.
No, it contains headers for the char-array-based string manipulation
functions inherited from C. They are still C++, although that
particular header is deprecated and should be replaced with the newer
one, <cstring>.

Brian
Jun 25 '07 #7
Erik Wikström wrote:

I'd like to add that none of the C++ standard headers have a .h in
them.
Not true. While deprecated, several .h headers are standard.

Brian
Jun 25 '07 #8
On Jun 25, 6:36 pm, Lionel B <m...@privacy.n etwrote:

[...]
Note: string.h contains headers for the standard C (as opposed to C++)
string manipulation routines. If you need these in C++ (and chances are
you don't if you're using std::string) then you should include them via
the header <cstringrathe r than string.h.
This would be good advice IF you could realiably count on a
conformant <cstring>. In practice, you can't, and you're
probably better off for the time being still using <string.h>.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 26 '07 #9
Default User wrote:
Erik Wikström wrote:

>I'd like to add that none of the C++ standard headers have a .h in
them.

Not true. While deprecated, several .h headers are standard.

Nope, there are no C++ headers that have .h, deprecated or otherwise.

What there exists are the C headers that the C++ standard includes
by reference. These can be done either by their C names (such
as stdio.h) or by a not-deprecated C++ interface (cstdio).

Any headers like iostream.h are not part of C++ (deprecated
or otherwise). Their vestiges of early non-standard implementations .
Jun 27 '07 #10

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

Similar topics

9
8698
by: David Carter-Hitchin | last post by:
Hi, I'm not very experienced with c++ so I'm sure this is something obvious that is easily solved, but for the life of me I can't seem to figure it out. I'd be very grateful for some knowledgeable insight into this. My class Position has a string (private, public - doesn't seem to matter which), which I construct in a member function and wish to return calls from main(). However, although
19
3191
by: Mike Tyka | last post by:
Hello community, i'm fairly new to using the STL but i've been experimenting a bit with it. I tried to derive a new class say MyString from string like so: class MyString: public string{ public: MyString(){} };
13
11021
by: M | last post by:
Hi, I've searched through the previous posts and there seems to be a few examples of search and replacing all occurrances of a string with another string. I would have thought that the code below would work... string gsub(const string & sData, const string & sFrom,
32
14878
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
1
5237
by: Simon | last post by:
Hi, I have a class that does not seem to work. I cannot see the problem, and the "fix" I have found does not help me understand what the problem was I know I don't need a copy constructor but the class might grow later and I prefer having my copy constructor. This also explains why I have 2 similar function "ClearAll() and NullAll()" they might be used later in case I have pointers.
5
7241
by: Martin Jørgensen | last post by:
Hello again, Sorry to bother but I guess my C++ book isn't very good since it obviously contains errors so the program code doesn't work with g++. However I don't understand what the problem is. Last time the problem was that "using namespace std" apparently had a "link" class/object defined already. Now I get: error: no matching function for call to 'String::String(String)'
6
2205
by: tommaso.gastaldi | last post by:
Hi, does anybody know a speedy analog of IsNumeric() to check for strings/chars. I would like to check if an Object can be treated as a string before using a Cstr(), clearly avoiding the time and resource consuming Try... Catch, which in iterative processing is totally unacceptable. -tom
3
1793
by: sernamar | last post by:
Hi, I have the following base class class UnitOfMeasure { public: //... std::string& GetName() {return _uomName;}; //... protected:
9
2097
by: jerry.upstatenyguy | last post by:
I am really stuck on this. I am trying to write a string array containing a "word" and a "definition" to a class called Entry. Ultimately this will end up in another class called dictionary. No, this is not a homework assignment. In fact it was a question on my class midterm that everyone bombed. Unfortunately we never covered this in class prior to the midterm. Anyway, please help if you would be so kind. Here is what I have. I...
3
4086
by: ryan.gilfether | last post by:
I have a problem that I have been fighting for a while and haven't found a good solution for. Forgive me, but my C++ is really rusty. I have a custom config file class: class ConfigFileValue { public: operator string(); // allow this class to be typecast into a string operator char*(); // allow this class to be typecast into a char*
0
8917
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.