Skip to main content

All Questions

Tagged with
3 votes
1 answer
15k views

Depreciated strlen(): Passing null to parameter #1 ($string) of type string is depreciated

your text The above warning is displayed in PHP 8.1 after upgrading from PHP 7.4 Any ideas on how this code can be changed for PHP 8.1 compatibility? private function cleanInput2($strRawText, $...
Andy's user avatar
  • 53
7 votes
6 answers
14k views

What if a null character is present in the middle of a string?

I understand that the end of a string is indicated by a null character, but i cannot understand the output of the following code. #include <stdio.h> #include <string.h> int main(void) { ...
Ranjan Srinivas's user avatar
0 votes
1 answer
737 views

Arduino. The length of NULL

This is not an question, I just want to share a headache I had for a while. Why I got 1 in: Serial.println(strlen(NULL)) Because of this macro: #define NULL ((char *)0) I was expecting 0, but ...
wchmb's user avatar
  • 1,345
0 votes
2 answers
818 views

strlen sometimes equal to sizeof for null-terminated strings

I know that strlen counts the number of characters up until (and excluding) the null character '\0' (or 0) and that sizeof gives the amount of space needed to store the string including the null ...
oobiic's user avatar
  • 15
0 votes
5 answers
148 views

How does strlen giving the same output for {'1','1'} and {'1','1','\0'}?

strlen() is terminated by null right? So how come both char c[]={'1','1'} and char d[]={'1','1','\0'} gives the same output 2 when strlen(c) and strlen(d) is used?
user2715898's user avatar
  • 1,001
0 votes
3 answers
314 views

How to ensure the string is full of spaces for a given length?

I have a bunch of strings that I need to verify if these have all spaces. I can do strlen(trim(strct.data)) > 0. But, it's not null terminated, but the length is known. i.e. if strct.len is 5 ...
San's user avatar
  • 4,133
4 votes
3 answers
2k views

How could a PHP value contain a string of zero length not equal to the empty string or null?

I am retrieving some data from an in-house store and in case of failure, I get a very specific response. Calling strlen() on this variable returns the value of zero. It is also not equal to NULL or "...
Erick Robertson's user avatar
1 vote
2 answers
10k views

How to know whether an array is initialized in C

How to know whether an array is initialized in C ? Functions like strlen() are not helping me as I dont want to know whether the array is empty or not.
Waseem's user avatar
  • 1,408