Questions tagged [string-length]

String length most commonly refers to the number of characters contained within a string. However, it could also mean the screen space a string takes up when printed.

This tag should be used for either of the two following types of questions:

  1. Those dealing with the number of characters contained within a string.
  2. Those dealing with measuring the size of a string (in pixels, millimeters, etc.) when it is printed on a screen.
1040 questions
-3
votes
1 answer

length of list in python?

I'm having the user input a file to open which contains numbers. I want the output to be the number of elements in the file. I put.. file=open(input("Please enter the name of the file you wish to open:" ))#, "r") A= file.readline() print…
-4
votes
0 answers

how should keep all efficient numbers those that are odd and have six digits

function findEfficientBulbs(serialNumbers) { console.log(serialNumbers); const efficientSerialNumbers = [] // Write your code here for (let i = 0; i < serialNumbers.length; i++){ const iNumber = serialNumbers[i] if…
-4
votes
3 answers

Find length of a string in SQL using LIKE operator

Example: Suppose there are following rows: 1- Animal is innocent 2- Dog is Animal select length(columnname like %animal%) from tablename o/p - 1-17 2-13
-4
votes
2 answers

Len function not returning the correct value for string

So I am trying to call the length of a coded message, and then divide that length by 3 (every 3 chars represents one letter). Here is the message: 10311132-10710510810832-121111117114115101108102 The dashs are set to be placed directly after…
Herobrine
  • 47
  • 1
  • 5
-4
votes
3 answers

C language. Length of the string without using null-termination

strlen() considers that '\00' is end of the string. How to calculate real length? E.g. there is AnsiString type in Pascal. It can contain many #$00 , but Length(s) will give correct result. Debugging of compiled pascal code shows that pascal puts…
-4
votes
3 answers

Specifying the length of Int containing 0s

I want to convert a string which contains 5 zeros ("00000") into a Int so it can be incremented. Whenever I convert the string to an integer using Convert.ToInt32(), the value becomes 0. How can I ensure that the integer stays at a fixed length once…
Rav
  • 121
  • 2
  • 3
  • 12
-4
votes
2 answers

Undesired Output

#include #include using namespace std; int main() { std::string a, b; int number_cases=0,i,j,count=0; cin>>number_cases; while(number_cases!=0) { cin>>a; cin>>b; …
-4
votes
3 answers

i have a php variable that i have to display the length of as a 3 digit number that is right aligned

this is a really noob question I guess, but I am very new to php and have no idea how to even begin this one, basically I have a set of $vars that I have to display the length of as a 3 digit number that is right justified. Any pointers as to how to…
Eric Edward
  • 23
  • 1
  • 1
  • 2
-5
votes
4 answers

how to write java string length method code?

what is the wrong of the following code , i am trying to write the length method source code , i tried it with c++ ( same logic i mean ) and it worked , but here it give me the below exception error : StringIndexOutOfBoundsException , thanks for…
-5
votes
2 answers

Why do I get zero length for a string filled element by element?

this is my issue. I am compiling with g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 I would like to check every element of the string, and copy it only if it is a consonant. This is how I try to do that: This is just a function to select vowels: bool…
-5
votes
1 answer

How to decide string length?

I have been curious to know How to decide string length ? When I asked my teacher this, he replied "you have to assume a value and allocate to srting". which eventually pushed me to my original question how to assume a specific length for a string.…
-5
votes
4 answers

Can i determine string length in c# doing something like this?

Out of curiosity I am trying to determine string length without using properties or methods, this is something that works in C, but still kind of new to this concept of \0. From what I understood, and I am talking about C, this character is…
Djordje
  • 437
  • 1
  • 12
  • 24
-5
votes
2 answers

How to not count special character and vowels occurences in string length using user input

I just got into my 2nd programming subject but my prof just throws stuff at us that he didn't teach so I'm guessing that I need help from people because searching the internet's help ain't enough So the output that I'm looking for is like this Enter…
-5
votes
2 answers

how does 'length' work to return the length of a String type array object in Java?

we have length()- a method that returns the length of a String object, for example: String s, sarr[] = {"a","b"}; System.out.println(s.length()); System.out.println(sarr.length); in Java. But what does happen, in background, in case of…
log0
  • 2,206
  • 2
  • 14
  • 24
-5
votes
2 answers

Why do we use 'strlen()' if 'printf()' itself returns the length of the string?

The C function printf() returns the no of characters printed then what makes strlen() different?
1 2 3
69
70