Found 1401 Articles for C

strspn() in C

Samual Sam
Updated on 24-Jun-2020 11:28:22

135 Views

The function strspn() is used to calculate the length of substring of first string which is present in second string. It returns the length of that substring.Here is the syntax of strspn() in C language,size_t strspn(const char *string1, const char *string2);Here is an example of strspn() in C language,Example Live Demo#include #include int main() {    const char s1[] = "Helloworld!";    const char s2[] = "Hello";    int length = strspn(s1, s2);    printf("The length of string : %d", length);    return 0; }OutputThe length of string : 5

strcoll() in C/C++

karthikeya Boyini
Updated on 24-Jun-2020 11:14:50

178 Views

The function strcoll() is used to compare two strings using locale - specific collating sequence.It returns −zero, when both strings are same, greater than zero value when first string is greater than otherless than zero value, when first string is less than other.Here is the syntax of strcoll() in C language, int strcoll(const char *first_string, const char *second_string);Here is an example of strcoll() in C language, Example Live Demo#include #include int main () {    const char s1[] = "Helloworld";    const char s2[] = "Blank";    char *result;    result = strcoll(s1, s2);    if(result > 0)   ... Read More

strpbrk() in C

Samual Sam
Updated on 24-Jun-2020 11:16:33

970 Views

The function strpbrk() is used to find the first character of first string and matches it to any character of second string. It returns NULL, if no matches are found otherwise, it returns a pointer to the character of first string that matches to the character of second string.Here is the syntax of strpbrk() in C language, char *strpbrk(const char *string1, const char *string2)Here is an example of strpbrk() in C language, Example Live Demo#include #include int main () {    const char s1[] = "Helloworld";    const char s2[] = "Blank";    char *result;    result = strpbrk(s1, ... Read More

scanf() and fscanf() in C

karthikeya Boyini
Updated on 24-Jun-2020 11:17:07

2K+ Views

Function scanf()The function scanf() is used to read formatted input from stdin in C language. It returns the whole number of characters written in it otherwise, returns a negative value.Here is the syntax of scanf() in C language, int scanf(const char *characters_set)Here is an example of scanf() in C language, Example Live Demo#include int main () {    char s[20];    printf("Enter a string : ");    scanf("%s", s);    printf("Entered string : %s", s);    return(0); }OutputEnter a string : Peter! Entered string : Peter!Function fscanf()The function fscanf() is used to read the formatted input from the given stream ... Read More

Difference between %d and %i format specifier in C

Samual Sam
Updated on 24-Jun-2020 11:17:57

2K+ Views

Format Specifier %dThe format specifier %d takes integer value as a signed decimal integer value which means values should be decimal whether it is negative or positive.Here is an example of format specifier %d in C language, Example Live Demo#include int main() {    int v1 = 7456;    int v2 = -17346;    printf("The value in decimal form : %d", v1);    printf("The value in negative : %d", v2);    return 0; }OutputThe value in decimal form : 7456 The value in negative : -17346Format Specifier %iThe format specifier %i takes integer value as an integer value which means ... Read More

atol(), atoll() and atof() functions in C/C++

karthikeya Boyini
Updated on 24-Jun-2020 11:18:30

553 Views

atol() FunctionThe function atol() converts string into a long integer. It returns zero, when no conversion is performed. It returns the converted long int value.Here is the syntax of atol in C++ language,long int atol(const char *string)Here is an example of atol() in C++ language,Example Live Demo#include using namespace std; int main() {    long int a;    char str[20] = "538756";    a = atol(str);    cout

iswdigit() function in C/C++

karthikeya Boyini
Updated on 24-Jun-2020 11:09:44

157 Views

The function iswdigit() is a built-in function in C/C++. It checks whether the wide character is a decimal digit or not. It is declared in “cwctype” header file in C++ language while “ctype.h” in C language. It takes a single character which is known as wide character.The characters from 0 to 9 are classified as decimal digits. If the wide character is not a digit, it will return zero(0). If character is digit, it will return non-zero value.Here is the syntax of iswdigit() in C++ language, int iswdigit(ch)Here is an example of iswdigit() in C++ language, Example Live Demo#include #include ... Read More

towupper() function in C/C++

Samual Sam
Updated on 24-Jun-2020 11:10:04

167 Views

The function iswupper() is a built-in function in C/C++. It converts the wide character into upper case. It is declared in “cwctype” header file in C++ language while “ctype.h” in C language. It takes a single character which is known as wide character. If the character is upper case, it is converted into it, otherwise no modifications happen.Here is the syntax of towupper() in C++ language, wint_t towupper( wint_t ch );Here is an example of towupper() in C++ language, Example#include #include #include using namespace std; int main() {    wchar_t s[] = L"hello world!";    wcout Read More

iswlower() function in C/C++

karthikeya Boyini
Updated on 24-Jun-2020 11:10:43

152 Views

The function iswlower() is a built-in function in C/C++. It checks whether the wide character is in lower case or not. It is declared in “cwctype” header file in C++ language while “ctype.h” in C language. It takes a single character which is known as wide character. It will return zero(0), if the character is not a lower case character. It will return non-zero value, if character is lower case.Here is the syntax of iswlower() in C/C++ language, int iswlower(ch);Here is an example of iswlower() in C++ language, Example Live Demo#include #include using namespace std; int main() {   ... Read More

How to use enums in C/C++?

karthikeya Boyini
Updated on 24-Jun-2020 11:11:44

719 Views

Enumeration is a user defined datatype in C language. It is used to assign names to the integral constants, which makes a program easy to read and maintain. The keyword “enum” is used to declare an enumeration.Here is the syntax of enum in C language, enum enum_name{const1, const2, ....... };The enum keyword is also used to define the variables of enum type. There are two ways to define the variables of enum type as follows.enum week{sunday, monday, tuesday, wednesday, thursday, friday, saturday}; enum week day;Here is an example of enum in C language, Example#include enum week{Mon=10, Tue, Wed, Thur, Fri=10, ... Read More

Advertisements