Hi,
I'm reading from a .dat file and I want to know the length of the
string .
I' using the stringRef.lengt h () but the compiler said there was an
error
`stringRef' undeclared (first use this function)
Is there any function in C++ to determine the lenght of the string??
Cheers! 8 7812 cd********@yaho o.co.uk skrev: Hi,
I'm reading from a .dat file and I want to know the length of the string .
I' using the stringRef.lengt h () but the compiler said there was an error
`stringRef' undeclared (first use this function)
Is there any function in C++ to determine the lenght of the string??
? Read the error message!
--
TB @ SWEDEN cd********@yaho o.co.uk wrote: Hi,
I'm reading from a .dat file and I want to know the length of the string .
I' using the stringRef.lengt h () but the compiler said there was an error
`stringRef' undeclared (first use this function)
Is there any function in C++ to determine the lenght of the string??
Your problem is not a missing function (it is there, trust me), but
a missing string. Cannot determine the length of something that is not
there, can you?
If you still cannot figure out what you are doing wrong, try:
#include <string>
int main ()
{
std::string s = "Hello";
s.length ();
}
hth
--
jb
(reply address in rot13, unscramble first) cd********@yaho o.co.uk wrote: Hi,
I'm reading from a .dat file and I want to know the length of the string .
What string? What is a .dat file?
I' using the stringRef.lengt h () but the compiler said there was an error
`stringRef' undeclared (first use this function)
Well, then I guess you forgot to declare stringRef.
Is there any function in C++ to determine the lenght of the string??
Yes, the lenght() member function (if you are referring to std::string).
<cd********@yah oo.co.uk> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. . Hi,
I'm reading from a .dat file and I want to know the length of the string .
I' using the stringRef.lengt h () but the compiler said there was an error
`stringRef' undeclared (first use this function)
Is there any function in C++ to determine the lenght of the string??
Yes, it is indeed .length() for std::string
It sounds more like your std::string stringRef is undefined. Most likely
you have a typo and misstyped the name of the function. Are you sure it
shouldn't be StringRef or soemthing? Compare where you declared stringRef
and how you're using it.
stringRef should be declared something like:
std::string stringRef;
"TB" <TB@SWEDEN> wrote in message
news:44******** **************@ taz.nntpserver. com... cd********@yaho o.co.uk skrev: Hi,
I'm reading from a .dat file and I want to know the length of the string .
I' using the stringRef.lengt h () but the compiler said there was an error
`stringRef' undeclared (first use this function)
Is there any function in C++ to determine the lenght of the string??
? Read the error message!
Would that be "RTEM"? :-)
Rolf Magnus wrote in message ...
""""""" cd********@yaho o.co.uk wrote: I' using the stringRef.lengt h () but the compiler said there was an error `stringRef' undeclared (first use this function)
Well, then I guess you forgot to declare stringRef.
Is there any function in C++ to determine the lenght of the string??
Yes, the lenght() member function (if you are referring to std::string).
"""""""
Don't forget to define it first:
#include <string> // C++
#include <iostream>
#include <ostream> // std::endl
size_t lenght(std::str ing const &Tstr){
return Tstr.size();
// or: return Tstr.length();
}
int main(){
std::string stringRef( "Yes, the lenght() member" );
std::cout<<" size of stringRef is "<<lenght( stringRef )<<std::endl;
return 0;
}
// output: size of stringRef is 24
--
Bob <G> R
POVrookie
"BobR" <Re***********@ worldnet.att.ne t> wrote in message
news:Vl******** *************@b gtnsc05-news.ops.worldn et.att.net... Rolf Magnus wrote in message ... """"""" cd********@yaho o.co.uk wrote:
I' using the stringRef.lengt h () but the compiler said there was an error `stringRef' undeclared (first use this function)
Well, then I guess you forgot to declare stringRef.
Is there any function in C++ to determine the lenght of the string??
Yes, the lenght() member function (if you are referring to std::string). """""""
Don't forget to define it first:
#include <string> // C++ #include <iostream> #include <ostream> // std::endl
size_t lenght(std::str ing const &Tstr){ return Tstr.size(); // or: return Tstr.length(); }
int main(){ std::string stringRef( "Yes, the lenght() member" ); std::cout<<" size of stringRef is "<<lenght( stringRef )<<std::endl; return 0; }
// output: size of stringRef is 24
May I assume we're actually talking about the "length" function here, not
the "lenght" function? :-)
Howard wrote in message ... "BobR" <Re***********@ worldnet.att.ne t> wrote in message ... Rolf Magnus wrote in message ... """"""" Is there any function in C++ to determine the lenght of the string??
Yes, the lenght() member function (if you are referring to std::string). """""""
Don't forget to define it first:
#include <string> // C++ #include <iostream> #include <ostream> // std::endl
size_t lenght(std::str ing const &Tstr){ return Tstr.size(); // or: return Tstr.length(); }
int main(){ std::string stringRef( "Yes, the lenght() member" ); std::cout<<" size of stringRef is "<<lenght( stringRef )<<std::endl; return 0; } // output: size of stringRef is 24
May I assume we're actually talking about the "length" function here, not the "lenght" function? :-)
Wal, ewe dint want me two tel hymn he spelt sumthin rong didja?
<G>
Anyway, maybe the OP will see something that will help them. (...and I,
hopefully, at least got a chuckle out of somebody).
The question is, does '*.length()' return '*.size()', or does '*.size()'
return '*.length()'?
Neither! Looking at my (MinGW GCC) basic_string.h:
// Capacity:
size_type size() const { return _M_rep()->_M_length; }
size_type length() const { return _M_rep()->_M_length; }
So, either one is as good as the other. (no extra 'call overhead')
--
Bob <G> R
POVrookie This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Smith |
last post by:
Hi,
I'm writing a library in C++ which is supposed to be used by people using C.
One function I have must return a string to users which is arbitrary length.
The user must be able to use this string as "char *" so I was wondering if
the following construct is safe:
char *Func()
{
static string str;
|
by: MLH |
last post by:
I'm working with lots of long strings now, it seems.
I have to import them & parse them constantly. The
A97 memo field type supports only 32768 chars.
What happens when this is processed...
Dim MyString As String
Am I getting VLS declaration or a FLS declaration?
Can I control which I get somehow?
I have done some homework, but I don't...
|
by: Jimski |
last post by:
Hello all,
I am having a problem where I get an error message when I call
FlushFinalBlock when decrypting my encrypted text. I am using the
Rijndael algorithm.
The error message is "Length of the data to decrypt is invalid" and
occurs on the csDecrypt.FlushFinalBlock.
|
by: gane kol |
last post by:
Hi
I am using DES algorithm. I am getting an error message in a few cases of
the querystring
Error Message : Length of the data to decrypt is invalid.
Error Method : System.String Decrypting(System.String)
Error Line: strDecrpt = sr.ReadToEnd();
QueryString Data:
|
by: Matt |
last post by:
Have below code
AcctNbr give me result of 30.
That is the database column length, Column stores 10 why is giving me
30 ?
while(objRead.Read())
{
AcctNbr = (string)objRead.ToString().Length;
Console.WriteLine("Length is {0}",AcctNbr.Length);
}
| |
by: Lyle Fairfield |
last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp
"If the value of the variant argument is Null, the Nz function returns
the number zero or a zero-length string (always returns a zero-length
string when used in a query expression)"
****
How many records are there in FirstTable in which...
|
by: Mavenos |
last post by:
Hi Web Masters,
Just wondering wether you can help us to come up with some tokenize
script.
My problem is wanted to display a LONG content into a short para (by
giving minimum letter lenght)
I mean if I have a 2 page content - just I want to display only 4 lines
having 200 letters then follows the content with "....." at the end of
|
by: Sathyaish |
last post by:
I have the following scenario:
Algorithm: 3DES
Cipher Mode: CBC
Key Size: 128-bit
Block Size: 64 bit
IV: 0x0000000000000000 (an eight byte array of zeros)
The results I get using .NET with the following routine are:
|
by: kellygreer1 |
last post by:
What is a good one line method for doing a "length safe"
String.Substring?
The VB classes offer up the old Left function so that
string s = Microsoft.VisualBasic.Left("kelly",200)
// s will = "kelly" with no error
// but
string s2 = "kelly".Substring(0,200)
// results in
// ArgumentOutOfRangeException
|
by: Rick Knospler |
last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for
the most part except for the fixed length strings and fixed length string
arrays. Bascially the vb6 programmer stored all form data in a fixed length
structure that is written direct to disk.
I need to load the existing files, into a fixed length structure to...
|
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. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |