Answers for "how to find length of char array"

C
2

length of a char array in c

char chararray[10];
size_t len = strlen(chararray);
Posted by: Guest on May-24-2020
0

chararray length

import java.util.Scanner;

public class FindLengthOfStringWithoutUsingLength {

	public static void main(String[] args) {
		int length=0;
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter a String");
        String s = sc.next();
        for (char c1 : s.toCharArray()) 
			length++;
		System.out.println("Length of String is : "+length);
		
	}

}
This code is contributed by Shubham Nigam (Prepinsta Placement Cell Student)
Posted by: Guest on June-10-2021

Code answers related to "how to find length of char array"

Code answers related to "C"

Browse Popular Code Answers by Language