Found 1339 Articles for C

strchr() function in C/C++

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

376 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

strxfrm() in C/C++

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

353 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

259 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

347 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

187 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

204 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

785 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++ ?

Tapas Kumar Ghosh
Updated on 11-Apr-2025 18:20:24

8K+ 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. Finding Size of a Void Pointer  To find the size of a void pointer, you can use the sizeof() operator that accepts a data type, variable name, or any value and returns its size. In this case, you need to pass the name of the void pointer. Syntax Following is the basic syntax of void ... Read More

fgets() and gets() in C

Samual Sam
Updated on 26-Jun-2020 07:46:12

2K+ Views

fgets()The function fgets() is used to read the string till the new line character. It checks array bound and it is safe too.Here is the syntax of fgets() in C language, char *fgets(char *string, int value, FILE *stream)Here, string − This is a pointer to the array of char.value − The number of characters to be read.stream − This is a pointer to a file object.Here is an example of fgets() in C language, Example Live Demo#include #define FUNC 8 int main() {    char b[FUNC];    fgets(b, FUNC, stdin);    printf("The string is: %s", b);    return 0; }OutputThe ... Read More

What should main() return in C/C++?

karthikeya Boyini
Updated on 26-Jun-2020 07:46:45

5K+ Views

The return value of main() function shows how the program exited. The normal exit of program is represented by zero return value. If the code has errors, fault etc., it will be terminated by non-zero value.In C++ language, the main() function can be left without return value. By default, it will return zero.Here is the syntax of main() function in C language, int main() {    ….    return 0; }Here is an example of main() function in C language, Example Live Demo#include int main() {    int a = 10;    char b = 'S';    float c = ... Read More

Advertisements