Questions tagged [strlen]

A standard C function that returns the length of a string.

This function calculates the length of the string, excluding the terminating null byte \0. It is defined in the <string.h> standard header.

Documentation for C strlen.

692 questions
2
votes
3 answers

If statements not working inside while loop

Only the 'strlen' function is being executed by the program. The if statements inside this while loop do not even work... #include #include #include main() { char cMessage[100]; int cLow = 0, cUp = 0, cSpec = 0,…
Ed Hernandez
  • 31
  • 1
  • 6
2
votes
4 answers

How to count the number of characters after the last comma

I have a string similar to the following and would like to count the number of the characters after the last comma. $test = "apple, orange, green, red"; $count = strlen($test); echo "$count"; and it should return 3. I have used the strlen command…
Alex
  • 55
  • 1
  • 7
2
votes
2 answers

How to find string length using scasb in Assembly

I have a string and am trying to find it's length. I am using rw32-2017. I tried to scan the string using repe scasb but it does not change the ZF at all. Is there a easier way to find the length of a string? My program: %include…
Adam
  • 99
  • 2
  • 8
2
votes
2 answers

Why does this REPNE SCASB implementation of strlen work?

Why does this code work? http://www.int80h.org/strlen/ says that the string address has to be in EDI register for scasb to work, but this assembly function doesn't seem to do this. Assembly code for mystrlen: global mystrlen mystrlen: sub …
NanoPish
  • 1,379
  • 1
  • 19
  • 35
2
votes
1 answer

Query on Wikibase:label REGEX & STRLEN

I'm new to SparkQL & wikidata and I'm trying to query the following: Male singers (artists/performers) Who are alive Given name = 6 characters Given name does NOT Contain ("e","i","u") I'm having trouble with the Filters on Given names (I…
M O'Connell
  • 487
  • 5
  • 18
2
votes
3 answers

Get random item after applying strlen in for loop

I'm trying to get a random element of an array after applying strlen within the loop FOR to see that words are greater than 5 characters, but at the moment I do not get the expected result. My code is as follows: $input = array("Neo", "Morpheus",…
Cristian Bustos
  • 357
  • 7
  • 20
2
votes
4 answers

Static char array initialization with simple function says length is 6, but shouldn't it be 1?

I've discovered that this program continues returning 6 until I start returning 16 or greater instead of 1, at which point the program prints 0. Why? My intention was to use pass the result of a function directly into the static array…
Dave Liu
  • 906
  • 1
  • 11
  • 31
2
votes
3 answers

Strlen Function behavior on single character

Here is my code: void func(char c) { char * ptr = &c; size_t len = strlen(ptr); printf("len - %d\n", len); } len is always printed as 1. strlen(..) determines the length of a char array by finding the null character (\0) at the end of…
viv
  • 45
  • 3
2
votes
3 answers

Checking validity of non null-terminated string

I am having trouble wrapping my brain around null terminators and non-null terminating arrays. Let's say I have two declarations: const char *string = "mike"; and const char string[4] = {'m', 'i', 'k', 'e'}; I understand the first declaration is…
Mike Henke
  • 641
  • 2
  • 10
  • 24
2
votes
1 answer

Why strpos + strlen is not secure in PHP (ex: exact matching)

I had a discussion with my teacher about the mb_ functions. Whatever, one thing leading to another, we changed the subject and he gave me an example where strpos and strlen could be problematic, according to him: $input = "something"; # input given…
Gana32
  • 21
  • 3
2
votes
1 answer

Buffer Overflow

I have been searching online for a few days but still cannot figure out what is the vulnerability for below code. My first thought is that we can do overflow for int 'length' and then do buffer overflow exploit to copy shell code and return address…
kevin
  • 21
  • 3
2
votes
3 answers

Setting minimum length of characters for post

I got code for posting title and body of blog along with few other things. Now I want to set minimum length of characters for title and body using strlen, my code is if(isset($_POST['submit'])) { $title=$_POST['title']; $body=$_POST['body']; …
user5311126
2
votes
3 answers

PHP: get remote file size with strlen? (html)

I was looking at PHP docs for fsockopen and whatnot and they say you can't use filesize() on a remote file without doing some crazy things with ftell or something (not sure what they said exactly), but I had a good thought about how to do it: $file…
John D.
  • 265
  • 4
  • 10
2
votes
4 answers

what should strlen() really return in this code?

#include #include #include int main(void) { char qq[] = {'a' , 'b' , 'c' , 'd'}; char qqq[] = "abcd"; printf("%d\n" , sizeof qq / sizeof qq[0]); // line A printf("%d\n" , strlen(qq)); // line B …
PPJack
  • 95
  • 1
  • 6
2
votes
1 answer

Frama-C \strlen function

I installed Frama-C Sodium (20150201) + the Jessie plugin, and I'm trying to reproduce the examples provided in the ACSL reference manual. But I can't use Jessie library functions (like \strlen) because every time I use one of them, I get errors…
Alex
  • 119
  • 12