/* with run-time library */
int len;
char* str;
len = strlen (str);
/* without run-time library */
int mystrlen (const char* str) {
int len;
while (*str != '\0') {
len++;
str++;
}
return len;
}
int len;
char* str;
len = mystrlen(str);
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
what is if(!(str[i]==32))
print c co com comp compu
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.
int main (void) { char buf[1024]; scanf ("Enter a string: %s", buf); printf ("The length of the string is %d chars long.\n", strlen (buf)); return 0; }
This is an assignment not a question.
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
i am sam
what is if(!(str[i]==32))
what is if(!(str[i]==32))
No.
print c co com comp compu
You find a language that can be targeted towards the .NET Framework. What you are suggesting is something related to string manipulation and you can work with delimiters.
#include<iostream> #include<string> int main() { std::string s("The quick brown fox jumps over the lazy dog"); std::cout<<s.c_str()<<std::endl; std::cout<<"The previous string is "<<s.size()<<" characters long."<<std::endl; }
length = strlen(string);
You can't. If you want to find the length of a String object, you must use at least one of the String methods. Simply iterate over your char* and count the number of characters you find before you reach the null character . int strLength(const char* str) { int length = 0; // take advantage of the fact that all strings MUST end in a null character while( str[length] != '\0' ) { ++length; } return length; }
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.