C Programming - Lecture 11 :String operation
When we use language such as C strings. Language such as C strings usually refers to one or more characters of a word or sentence which is formed at the end of a NULL character (which is zero) it.
Below are some examples of string Let
"Hello World"

"Sirajganj"
"I"
Although it may be a character string. The single-coat the 'I' and thus will not be stri likhare it.
The stringula we can be helpful to print directly console
A string input from the user to use the scanf or gets two functions. To input a word and a whole line scanf gets input for the convenient use. Of course, any kind of input that can be used by scanf. Below we take a look at a few examples of the two yansanerai.
First, we input output Sting.
include studio.
int main (int arg, char * arg [])
{
char name
printf (My name).
return 0;
}
Progrimati two runs in the bottom of the first dbitibara Maruf Maniruzzaman Manir and keyboards as input has been typed. In the second case, only the first word is input.
Enter your name: Manir
Hello Maruf Maniruzzaman.
Enter your name here Monir.
Hello Maruf
Now we want the whole line input nite
include studio.
{
printf ( Enter your ).
gets,
printf ( My ID).
return 0.
}
Let runs on output
Enter your name: Maruf Maniruzzaman
Hello Maruf Maniruzzaman.
Another sting variables we use stop copy.
The prototype is provided below:
character (const char desert, const character search).
Examples:
{
char str1 [50], str2 [100];
strcpy (str2, str1)
return 0;
}
Let scoring output
Enter something Hello world.
You entered Hello world.
strcmp
We used to compare two strings strcmp do
int strcmp (const char * string1, const char * string2)
Examples:
int main (integer argument, character argument ).
gets (starth12)
gets (str2);
int comp = start camp (start1, start 2).
printf ( The strings are same).
}
printf ( First string is less than second string).
else
return 0;
}
Let scoring output.
Has twice times. For the first time both have the same input string. I have made a separate second string
Enter first STRING: TEST STRING
SECOND STRING Enter: TEST STRING
Strings are The Same.
Enter first STRING: Apple
Enter SECOND STRING:
strlen
We have to find out how the length of a string strlen use
this function prototype is provided below:
int strlen (const char * string)
Examples:
int main (int argc, char * argv [])
gets (str1);
int length = strlen (str1)
return 0;
}
Enter something: I love Bangladesh.
You entered a string of length 18
Another string to attach a string to use for
The function prototype is provided below:
char (constant character string1, char string2, size).
Examples:
int main (int argc, char argv)
{
char str1 str2 .
}
Enter first string:
Hello World !!
There are some functions that you can try out themselves. Although not the first time there is a problem. Keep in mind, however, that some functions sudho.
To compare two string comparison of the first n characters of the strncmp use
int strncmp (const char * string1, char * string2, size_t n)
The first n characters of a string with another string to attach the strncpy use
char * strncpy (const char * string1, const char * string2, size_t n)
We will compare two string strcasecmp uppercase characters use small or when we do not want to consider a separate
int strcasecmp (const char * s1, const char * s2)
To compare two string comparison of the first n characters of the strncasecmp use small or uppercase characters when we do not want to consider a separate
int strncasecmp (const char * s1, const char * s2, int n).


No comments: