How I make to determine the length of one string?
example
String[ ] = 'Ciao mamma come stai ' ;
this tightens is composed from 21 characters. how I make to realize a program that counts me the length of strings ?
How I make to determine the length of one string?
example
String[ ] = 'Ciao mamma come stai ' ;
this tightens is composed from 21 characters. how I make to realize a program that counts me the length of strings ?
http://linuxdesktop.it
Code:#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char msg[] = "Ciao mamma come stai "; printf("Length of \"%s\" is %d\n", msg, strlen(msg)); return 0; }
Do you need to write your own function (ie, is it homework/assignment) or do you just want to know how to get the length of a string? If it's the latter, the code below should help you along, if it's the former, well you need to have a go and post some code, then we'll help make it work.
strlen is in the header string.h
Code:#include <stdio.h> #include <string.h> int main(void) { char *string = "'Ciao mamma come stai"; printf("%d\n", strlen(string)); return 0; }
Demonographic rhinology is not the only possible outcome, but why take the chance