- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1452 Articles for C
203 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
115 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
139 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
587 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
6K+ 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
5K+ Views
malloc()The function malloc() is used to allocate the requested size of bytes and it returns a pointer to the first byte of allocated memory. It returns null pointer, if fails.Here is the syntax of malloc() in C++ language, pointer_name = (cast-type*) malloc(size);Here, pointer_name − Any name given to the pointer.cast-type − The datatype in which you want to cast the allocated memory by malloc().size − Size of allocated memory in bytes.Here is an example of malloc() in C language, Example Live Demo#include #include int main() { int n = 4, i, *p, s = 0; p = ... Read More
1K+ 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
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
8K+ Views
The datatype size_t is unsigned integral type. It represents the size of any object in bytes and returned by sizeof operator. It is used for array indexing and counting. It can never be negative. The return type of strcspn, strlen functions is size_t.Here is the syntax of size_t in C language, const size_t var_name;Here, var_name − This the name of variable.Here is an example of size_t in C language, Example Live Demo#include #include #include int main(void) { const size_t x = 150; int a[x]; for (size_t i = 0;i < x; ++i) a[i] = ... Read More
588 Views
Pointer arithmetic is used to implement arithmetic operations like addition subtraction, increment etc. in C language. There are four pointer arithmetic such as addition, subtraction, increment and decrement. In 32-bit machine, it increments or decrement the value by 2 and it will add or subtract 2* number. In 64-bit machine, it increments or decrement the value by 4 and it will add or subtract 4* number.Here is an example of pointer arithmetic in C language, Example Live Demo#include int main() { int val = 28; int *pt; pt = &val; printf("Address of pointer : %u", pt); ... Read More
To Continue Learning Please Login
Login with Google