Found 1401 Articles for C

strchr() function in C/C++

Samual Sam
Updated on 26-Jun-2020 08:03:47

288 Views

The function strchr() is used to search the character in the string. It search the first occurrence of character which is passed as second argument and it returns a pointer to the character, if successful otherwise, NULL.Here is the syntax of strchr() in C language, char *strchr(const char *string , int character)Here, string − The string which is to be scanned to search the character.character − The character which is to be searched in the string.Here is an example of strchr() in C language, Example Live Demo#include #include int main() {    char s[] = "Helloworld!";    char c = 'o'; ... Read More

Union in C

karthikeya Boyini
Updated on 26-Jun-2020 08:04:15

556 Views

Union is a user defined datatype. All the members of union share same memory location. Size of union is decided by the size of largest member of union. If you want to use same memory location for two or more members, union is the best for that.Unions are similar to the structure. Union variables are created in same manner as structure variables. The keyword “union” is used to define unions in C language.Here is the syntax of unions in C language, union union_name {    member definition; } union_variables;Here, union_name − Any name given to the union.member definition − Set ... Read More

Structures in C

Samual Sam
Updated on 26-Jun-2020 07:50:01

832 Views

Structure is a user defined datatype. It is used to combine the different types of data into single type. It can have multiple members and structure variables. The keyword “struct” is used to define structures in C language. Structure members can be accessed by using dot(.) operator.Here is the syntax of structures in C language, struct structure_name {    member definition; } structure_variables;Here, structure_name − Any name given to the structure.member definition − Set of member variables.structure_variable − This is the object of structure.Here is an example of structures in C language, Example Live Demo#include #include struct Data { ... Read More

strxfrm() in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 07:51:52

235 Views

The function strxfrm() transforms the source string to the current locale and copies the first number of characters of transformed string to the destination. It is declared in “locale.h” header file in C language.Here is the syntax of strxfrm() in C language, size_t strxfrm(char *destination, const char *source, size_t number)Here, destination − The destination pointer where the characters will be copied.source − The string is to be transformed.number − The number of characters to be copied.Here is an example of strxfrm() in C language, Example#include #include int main () has {    char s[10] = "HelloWorld";    char ... Read More

islessequal() in C/C++

Samual Sam
Updated on 26-Jun-2020 07:52:25

151 Views

The function islessequalr() is used to check that first argument is less than or equal to the second. It is declared in “math.h” header file. It returns true, if successful otherwise false.Here is the syntax of islessequal()bool islessequal(value1 , value2);Here, value1 − This is the first argument which will be checked with value2.value2 − This is the second argument which is used to check value1 that is less or equal.Here is an example of islessequal()Example Live Demo#include #include using namespace std; int main() {    int val1 = 8;    int val2 = 8;    bool result;    result = islessequal(val1, ... Read More

strcspn() in C

karthikeya Boyini
Updated on 26-Jun-2020 07:52:51

221 Views

The function strcspn() counts the number of characters before first match of characters in both strings. This is declared in “string.h” header file. It returns the number of characters of first string before the occurrence of first matched character.Here is the syntax of strcspn() in C language, size_t strcspn(const char *string1, const char *string2)Here, string1 − The first string which is to be scanned.string2 − The second string which is used to search the matching character in first string.Here is an example of strcspn() in C language, Example Live Demo#include #include int main() {    char str1[] = "Helloworld!";    char ... Read More

iswpunct() function in C/C++

Samual Sam
Updated on 26-Jun-2020 07:53:21

118 Views

The function iswpunct() is used to check that the passing wide character is a punctuation or not. It returns zero, if it is not a punctuation, otherwise it returns a non-zero value. It is declared in “cwctype” header file.Here is the syntax of iswpunct()int iswpunct(wint_t character);Here is an example of iswpunct()Example#include #include using namespace std; int main() {    wint_t a = '!';    wint_t b = 'a';    if(iswpunct(a))    printf("The character is a punctuation.");    else    printf("The character is not a punctuation.");    if(iswpunct(b))    printf("The character is a punctuation.");    else    printf("The character is not ... Read More

iswblank() function in C/C++

Samual Sam
Updated on 26-Jun-2020 07:55:24

143 Views

The function iswblank() is used to check that the passed wide character is blank or not. It is basically a space character and it also considers tab character(\t). This function is declared in “ctype.h” header file in C language and “cctype”” header file in C++ language.Here is the syntax of isblank() in C++ language, int iswblank(wint_t char);Here is an example of iswblank() in C++ language, Example Live Demo#include #include using namespace std; int main() {    wchar_t s[] = L"The space between words.";    int i = 0;    int count = 0;    while(s[i]) {       ... Read More

isblank() in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 07:56:11

614 Views

The function isblank() is used to check that the passed character is blank or not. It is basically a space character and it also considers tab character(\t). This function is declared in “ctype.h” header file in C language and “cctype”” header file in C++ language.Here is the syntax of isblank() in C++ language, int isblank(int char);Here is an example of isblank() in C++ language, Example Live Demo#include #include using namespace std; int main() {    string s = "The space between words. ";    int i = 0;    int count = 0;    while(s[i]) {       ... Read More

What is the size of void pointer in C/C++?

karthikeya Boyini
Updated on 26-Jun-2020 07:42:28

7K+ Views

The size of void pointer varies system to system. If the system is 16-bit, size of void pointer is 2 bytes. If the system is 32-bit, size of void pointer is 4 bytes. If the system is 64-bit, size of void pointer is 8 bytes.Here is an example to find the size of void pointer in C language, Example Live Demo#include int main() {    void *ptr;    printf("The size of pointer value : %d", sizeof(ptr));    return 0; }OutputThe size of pointer value : 8In the above example, a void type pointer variable is created and by using sizeof() ... Read More

Advertisements