answersLogoWhite

0


Best Answer

size_t my_strlen (const char str [])
{
size_t i;

for (i=0; str[i]; ++i);
return i;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Program in c string length in window using array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program to input a string in the form of name and swap the initials of the namefor example enter a string is rohit Kumar sharma and should be printed RK Sharma?

Get the string from user , then U Split the string with space and put in a string array .Then Find Length of string array , Take first letter of each element in array, Except last. Assigned those to a string, then Fetch Last element of an array, Add it With that String.That's it.


Can you give an example of array using character variable in c program?

the example of array over charcter variables is char ["string"]


Write a java program to initialize array of string with the days of the week?

final String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};


How many constructors are there for the string class?

The String class has multiple Constructors. Some of them are: 1. String - new String(String val) 2. Character Array - new String(char[] array) 3. Character Array with index positions - new String(char[] array. int start, int end)


No of occurrence of element in an array?

The below is an example to find the instance of a string in a string array. You can modify this to any kind of array and also pass the array and value to be checked as parameters. public class ArrayTest { /** * @param args */ public static void main(String[] args) { String[] strArr = new String[] {"One", "Two", "Three", "Four", "One"}; String txt = "One"; int size = strArr.length; int counter = 0; for(int i = 0; i < size; i++){ String temp = (String) strArr[i]; if(temp.trim().equals(txt)){ counter++; } } System.out.println("The word '" + txt + "' occurs " + counter + " Times in the array"); } } The output of this program would be: The world 'One' occurs 2 Times in the array

Related questions

Write a program to input a string in the form of name and swap the initials of the namefor example enter a string is rohit Kumar sharma and should be printed RK Sharma?

Get the string from user , then U Split the string with space and put in a string array .Then Find Length of string array , Take first letter of each element in array, Except last. Assigned those to a string, then Fetch Last element of an array, Add it With that String.That's it.


Write a program to reverse the given string?

Use for loop declare string array str[] and string variable l= string length of string array j=l for i=0 to i=l/2 then temp=str[i] str[i]=str[j-1] str[j-1]=temp j=j-1 now print str array it will be reversed


How strings and characters are represented in an array?

An array of characters is an array of character codes (such as ASCII codes). A string is typically a null-terminated array of characters however some languages use the first array element to specify the string's length.


Which function is used to retrive the part of the string?

If a string features a separator (e.g. a dot or a comma), use PHP's explode() function to get an array with the two parts: $string = "hello,joe" $array = explode(",", $string); $array[0] will be "hello" $array[1] will be "joe" If not, you may use substr() to return a certain length of a string


What is the difference between string and char array?

3 differences.................. 1. length wise.... 2.initialization 3. null terminated length of char array is differ from string........ initialization of string is differ from char....... and string is null terminated...........


Can you give an example of array using character variable in c program?

the example of array over charcter variables is char ["string"]


Why is c string defined as an array?

Every programming language treats strings as arrays. A C string is defined as being a null-terminated array of characters. A C string that does not have a null-terminator is just an array of character values, but without a null-terminator the onus is upon the programmer to keep track of the array's length.


Write a java program to initialize array of string with the days of the week?

final String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};


What is the array of string in c?

A string in C is stored in a 1 dimension array so an array of strings is simply a two dimension array.


How many constructors are there for the string class?

The String class has multiple Constructors. Some of them are: 1. String - new String(String val) 2. Character Array - new String(char[] array) 3. Character Array with index positions - new String(char[] array. int start, int end)


No of occurrence of element in an array?

The below is an example to find the instance of a string in a string array. You can modify this to any kind of array and also pass the array and value to be checked as parameters. public class ArrayTest { /** * @param args */ public static void main(String[] args) { String[] strArr = new String[] {"One", "Two", "Three", "Four", "One"}; String txt = "One"; int size = strArr.length; int counter = 0; for(int i = 0; i < size; i++){ String temp = (String) strArr[i]; if(temp.trim().equals(txt)){ counter++; } } System.out.println("The word '" + txt + "' occurs " + counter + " Times in the array"); } } The output of this program would be: The world 'One' occurs 2 Times in the array


How do you convert a string into a character array?

A string is, by definition, a character array. No conversion is required.