void main()
{
char str1[30];
char str2[30];
int len1,len2;
printf("Enter string1......:");
gets(str1);
printf("Enter string2......:");
gets(str2);
len1=strlen(str1);
len2=strlen(str2);
printf("%s length = %d",str1,len1);
printf("%s length = %d",str2,len2);
}
#include
#include
int main (int argc, char **argv)
{
int i;
for (i=0; i
printf ("strlen ("%s") is %d\n", argv[i], strlen (argv[i]));
}
return 0;
}
sdfdg
In JavaScript: To find the length of the string we you length method. __ __ __ Click the button to return the number of characters in the string "Hello World!". click here __ __ function myFunction() { var str = "Hello World!"; var n = str.length; document.getElementById("demo").innerHTML = n; } __ __ __ Hope this helps. Thank you
We'll use a simple method of encryption: xor encryption // same function used to both encrypt and decrypt void crypt(char *str) { const int key = 0x86; // crypt each individual character of str int i; const int length = strlen(str); for(i = 0; i < strlen(str); ++i) { str[i] = str[i] ^ key; } }
//C++ program to abbreviate first and middle name#include#include void main(void) { char name[40]; char abname[30]; int i,len,m=1,j=0; //puts is used to print string of characters //although cout is equivalent to it but gets //and cout should not be mixed in one program puts("Enter Name: "); //gets is used to take string input with spaces gets(name); //strlen is a built-in function, declared in //the string.h header file //it returns the length of a string len=strlen(name); abname[j++]=name[0]; abname[j++]='.'; abname[j++]=' '; for (i=0;i
#include<stdio.h> #include<string.h> int main() { char a[80]; int rotated_element_number[80]; int rotation; int i; int length; printf("enter the word: \n"); gets(a); length = strlen(a); printf("the reversed string is:\n"); for( rotation=0; rotation<length; rotation++) { for( i=0; i<length; i++) { rotated_element_number[i] = i + rotation; while(rotated_element_number[i] > (length-1)) rotated_element_number[i] -= length; printf("%c", a[rotated_element_number[i]]); } printf("\t"); } getchar(); return 0; }
sdfdg
In JavaScript: To find the length of the string we you length method. __ __ __ Click the button to return the number of characters in the string "Hello World!". click here __ __ function myFunction() { var str = "Hello World!"; var n = str.length; document.getElementById("demo").innerHTML = n; } __ __ __ Hope this helps. Thank you
You can write 2X, where X is the length of the string.
#include<stdio.h> #include<conio.h> void main() { char string[20]; int i=0; printf("Enter the string.\n"); while(i<=19) { scanf("%c",&string[i]); i++; } while(i>=0) { printf("%c",string[i]); i--; } getch(); } In this program it is compulsory to enter 20 characters. Now we can write a program in which it is not necessary. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char string[20]; int length; printf("enter the string.\n"); gets(string); length=strlen(string); length--; while(length>0) { printf("%c",string[length]); length--; } getch(); }
We'll use a simple method of encryption: xor encryption // same function used to both encrypt and decrypt void crypt(char *str) { const int key = 0x86; // crypt each individual character of str int i; const int length = strlen(str); for(i = 0; i < strlen(str); ++i) { str[i] = str[i] ^ key; } }
use strcat, strncpy, stpcpy, sprintf, strlen+memcpy, etc
//C++ program to abbreviate first and middle name#include#include void main(void) { char name[40]; char abname[30]; int i,len,m=1,j=0; //puts is used to print string of characters //although cout is equivalent to it but gets //and cout should not be mixed in one program puts("Enter Name: "); //gets is used to take string input with spaces gets(name); //strlen is a built-in function, declared in //the string.h header file //it returns the length of a string len=strlen(name); abname[j++]=name[0]; abname[j++]='.'; abname[j++]=' '; for (i=0;i
#include<stdio.h> #include<string.h> int main() { char a[80]; int rotated_element_number[80]; int rotation; int i; int length; printf("enter the word: \n"); gets(a); length = strlen(a); printf("the reversed string is:\n"); for( rotation=0; rotation<length; rotation++) { for( i=0; i<length; i++) { rotated_element_number[i] = i + rotation; while(rotated_element_number[i] > (length-1)) rotated_element_number[i] -= length; printf("%c", a[rotated_element_number[i]]); } printf("\t"); } getchar(); return 0; }
Yes.
what is string
Hay buddy this is homework. U have to solve it by urself.
int mystrlen (const char *s) { const char *t; if (!s) return 0; for (t=s-1;*++t;); return t-s; }