explain various string oriented I/O statements in c with an example each
Answers
Answered by
1
Answer:
Check below explanation
Explanation:
String handling function: strings are not accepting arthemetic and relational operators directly in c. so that is why c developers are introduced <string.h> to perform any type of string operations.
Ex:
- strcpy(): strcpy() stands for string copy this function is use copy string to another place
Ex: strcpy (forget string,source string);
- strlen(): strlen() stands for string length this function is used to find the length of the given string
Ex: strlen(stringname);
Answered by
2
Answer:
The following are the input and output functions of strings in c
Input functions: scanf(), gets()
Output functions: printf(), puts()
Explanation:
- To output the string, we use printf() function together with the format specifier %s.
- puts() is use to display only one string at a time.
- we use the scanf() function to read a string.
- The scanf() function reads the sequence of characters until it encounters whitespace.
- scanf() is not capable of receiving multi-word strings. For that we use gets() function.
- Though gets() is capable of receiving only one string at a time, the plus point is it can receive a multi-word string.
- In scanf(), no need to use 'address of' operator '&' before String variable name. This is because name is a char array, and we know that array names decay to pointers in C.
- Thus, the name in scanf() already points to the address of the first element in the string, which is why we don't need to use &.
Similar questions