Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
strlen
- Page 1
strlen
Programming
Software Development
14 Years Ago
by hystaspes
…; size_t sizeOfText; }; // Define the constructor. String::String( char *ch ) { sizeOfText =
strlen
( ch ) + 1; // Dynamically allocate the correct amount of memory. _text… be one unit more than "ch"? [CODE] sizeOfText =
strlen
( ch ) + 1; _text = new char[ sizeOfText ]; strcpy_s( _text, sizeOfText, ch…
strlen
Programming
Software Development
15 Years Ago
by buzzykerbox
…)time(NULL)); num = rand() % 9 + 0; word_to_guess = words[num]; size =
strlen
(word_to_guess); [/CODE]
Re: strlen
Programming
Software Development
15 Years Ago
by Fbody
…; post, but I thought I should clarify daviddoria's response.
strlen
() only works with C-style strings (null-terminated arrays of…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by duggydiggy
… alright in VS ,will call my
strlen
. But on top of gcc , my
strlen
function is not called...instead by default… is that? because when I look into symbol table
strlen
is resolved statically To be more specific I am pasting…[b]0000006e g F .text 0000002f
strlen
[/b] [/code] Above
strlen
(which is my
strlen
) is bounded with an known offset so…
strlen of strdup
Programming
Software Development
15 Years Ago
by monkey_king
… depends on uninitialised value(s) ==25636== at 0x4C26D29:
strlen
(mc_replace_strmem.c:242) ==25636== by 0x40060A: main (…test.c:7) [/CODE] [*]Question
Strlen
doesnt apparantly tell you how much space you have in… printf("length of str1:%d\n",(int)
strlen
(str1)); str1 = "test_of_string\n"; printf…
Strlen help needed. Got some questions to ask ^ ^
Programming
Software Development
16 Years Ago
by dexter1984
…stats.getline(counter,200); for (int i=0; i<
strlen
(counter); i++) { if (isupper(counter[i])) upper++; if…assignment but I'm still confused about the
strlen
command. Above is the section of code …though. When i tried using [QUOTE]total =
strlen
(counter)[/QUOTE] The result is not what I want…
strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by duggydiggy
…stdio.h> #include <conio.h> int
strlen
(const char *); int main() { char str[]="rahul&…quot;; printf("%d",
strlen
(str)); _getch(); return 0; } int
strlen
(const char *str) { const char… Length:6 //correct If I edit the
strlen
function as [CODE] int
strlen
(const char *str) { const char *…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by duggydiggy
…* 000001b9 __libc_start_main@@GLIBC_2.0 [B]08048442 g F .text 0000002c
strlen
[/B] 08048544 g O .rodata 00000004 _IO_stdin_used 0804a00c g .data… 00000000 _init [/code] looks to me like static linking of
strlen
but standard libraries are resolved dynamically. Please if one can…
Re: strlen of strdup
Programming
Software Development
15 Years Ago
by Salem
…, then you try and "read" that memory (using
strlen
) to find a \0 Besides which, it's also a… my new array also hold 80 or just till the
strlen
of the old char array? Minimally, just the space needed… tell that has happened, as all you officially have is
strlen
()+1 bytes.
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by gerard4143
… interesting [CODE] #include <stdio.h> size_t
strlen
(const char *s); int ans = 0; int main(int… argc, char**argv) { return ans =
strlen
("gerard"); } size_t
strlen
(const char *s) { int i = 0; while… the object dump...The compiler is calculating the
strlen
an placing the value directly into my global …
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by gerard4143
…function call [CODE] #include <stdio.h> size_t
strlen
(const char *s); int ans = 0; int main(int…gt;", stdout); fgets(ch, 19, stdin); return ans =
strlen
(ch); } size_t
strlen
(const char *s) { int i = 0; while (*s…thing at work...Shouldn't it return the normal
strlen
result instead of the one I defined here...It…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by gerard4143
… <stdio.h> typedef size_t(*pfunc)(const char*); size_t
strlen
(const char *s); int ans = 0; int main(int argc…, char**argv) { pfunc tfunc = (pfunc)
strlen
; return ans = tfunc("gerard"); } size_t
strlen
(const char *s) { int i = 0; while…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by gerard4143
… the function call [CODE] #include <stdio.h> size_t
strlen
(const char *s); int ans = 0; int main(int argc…->", stdout); fgets(ch, 19, stdin); return ans =
strlen
(ch); } size_t
strlen
(const char *s) { int i = 0; while (*s++) ++i…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by gerard4143
…=duggydiggy;998236]Tell me how can a compiler calculate the
strlen
if it does not know what the string is.You… value and is this so hard to conceive - we use
strlen
all the time maybe they(gcc) decide to allow optimization… len of a string - so when we substitute our own
strlen
function(one that doesn't return a standard string length…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by duggydiggy
…,,linking.. where compiler can assume only. [QUOTE] we use
strlen
all the time maybe they(gcc) decide to allow optimization…of a string - so when we substitute our own
strlen
function(one that doesn't return a standard string …criteria to decide to like how complex the function is...
strlen
is a simple function.. compiler can deal with this...…
Re: Strlen help needed. Got some questions to ask ^ ^
Programming
Software Development
16 Years Ago
by Ancient Dragon
I think you misunderstood what
strlen
() does -- it returns the number of characters in the buffer up to, but not including, the first byte that contains 0. That is normally smaller than the number of characters that the buffer can hold. Example: [icode]char buffer[255] = "Hello";[/icode] In the above,
strlen
() will return 5.
Re: strlen of strdup
Programming
Software Development
15 Years Ago
by fpmurphy
…. [code] printf("length of str1:%d\n",(int)
strlen
(str1)); [/code] In the next line of code you lose…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by duggydiggy
… of doing analysis of all the three ways [code] int
strlen
(const char *str) { const char *eostr=str; while(*eostr++); return… better code than both ?? Lets try this one !! [code] int
strlen
(const char *str) { const char *eostr=str; while(*eostr) eostr…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by Dave Sinkula
…'ll sidestep the why for a moment and mention that
strlen
is a reserved identifier and simply should not be used….1.2.3). [/quote] [CODE]identifier context header ISO ANSI
strlen
ext string.h 7.11.6.3 4.11.6…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by gerard4143
… 00000000 *UND* 00000000 printf [b]0000006e g F .text 0000002f
strlen
[/b] [/code] I notice your symbol table is for main… with the libraries yet?...Or is that your point that
strlen
is resolved here so why is it linking to the…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by duggydiggy
… [/quote] yes behaving same on my side. This is coz
strlen
is getting linked statically ..not only static linking but also… something inline that function has to be statically linked(here
strlen
)..but codes cannot be patched(or made inline) at runtime…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by gerard4143
… works. yes behaving same on my side. This is coz
strlen
is getting linked statically ..not only static linking but also… something inline that function has to be statically linked(here
strlen
)..but codes cannot be patched(or made inline) at runtime…
Re: strlen behaving strangley ??
Programming
Software Development
15 Years Ago
by duggydiggy
… mysterious thing at work...Shouldn't it return the normal
strlen
result instead of the one I defined here...It doesn… away...[/QUOTE] Tell me how can a compiler calculate the
strlen
if it does not know what the string is.You…
Re: Strlen help needed. Got some questions to ask ^ ^
Programming
Software Development
16 Years Ago
by Ancient Dragon
first problem: the while statement is incorrect. Here is how to do it. [icode]while( stats.getline(counter,200) )[/icode] Why do you think
strlen
() doesn't work? Its been working correctly for millions of programmers all over the globe for over 25 years, so I doubt it has a bug.
Re: Strlen help needed. Got some questions to ask ^ ^
Programming
Software Development
16 Years Ago
by dexter1984
I tried using [iCODE]total =
strlen
(counter)[/iCODE] to replace my total++ but I get 16 …
Re: Strlen help needed. Got some questions to ask ^ ^
Programming
Software Development
16 Years Ago
by dexter1984
Aaaa I see, my lecture notes had a similar example and it used the while eof() loop. I'll go read up more on the
strlen
command. Thanks again. :)
strlen in for loop
Programming
Software Development
9 Years Ago
by COKEDUDE
…bunch of unnecessary iterations in a for loop with
strlen
doesn't it also produce weird behaviors? http…://www.cprogramming.com/tips/tip/dont-use-
strlen
-in-a-loop-condition The documentation uses size_t instead…look. http://www.cplusplus.com/reference/cstring/
strlen
/ http://www.tutorialspoint.com/c_standard_library/c_function_strlen.htm
strlen() won't take iterator?
Programming
Software Development
17 Years Ago
by JRM
… the length of the the string , then display the test.
strlen
() is not cooperating! Am I using the wrong function? the…()) { cout<< << "length= "<<
strlen
(*itr) << " "<< *itr++ <<…
strlen of array
Programming
Software Development
12 Years Ago
by rithish
…<n;i++) { scanf("%s",a[i]); } j=
strlen
(a[0]); printf("%d",j); } here for example…[0] in 15 th line i have done that j=
strlen
(a[0]) is it possible
Re: strlen in for loop
Programming
Software Development
9 Years Ago
by rproffitt
This is one of those "it depends" questions. If you compile with GCC and other compilers, well, not to give away the answer so read: http://ridiculousfish.com/blog/posts/will-it-optimize.html There's another issue with [
strlen
() is it is still dangerous at times](http://ridiculousfish.com/blog/posts/will-it-optimize.html).
1
2
3
17
Next
Last
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2025 DaniWeb® LLC