
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 1339 Articles for C

21K+ Views
In C, we have various methods to clear the console or output screen and one of them is clrscr() function. It clears the screen as function invokes. It is declared in "conio.h" header file. There are some other methods too like system (cls) and system ("clear") and these are declared in "stdlib.h" header file. Syntax Following are the list of syntaxes to clear the console in C programming language as follows: clrscr(); Or, system("cls"); Or, system("clear"); Let’s say we have "new.txt" file with the following content: 0, hell!o 1, hello! 2, gfdtrhtrhrt 3, ... Read More

190 Views
The function mbrlen() is used to get the length of multibyte character. It returns the size of multibyte character pointed by the pointer.Here is the syntax of mbrlen() in C language, size_t mbrlen(const char* pointer, size_t size, mbstate_t* state);Here, pointer − Pointer to the first byte of multibyte character.size − Number of bytes to check.state − Pointer to the object of mbstate_tHere is an example of mbrlen() in C language, Example Live Demo#include #include #include int main(void) { char a[] = "s"; mbstate_t s; int len; len = mbrlen(a, 5, &s); printf("Length of ... Read More

399 Views
The function raise() is used to send the signals to the program. The predefined function signal() is invoked. It is implemented to check whether it will ignore the signal or invoke the signal handler. This is declared in “signal.h” header file. It returns zero, if successful otherwise, non-zero value.Here is the syntax of raise() in C language, int raise(int signal)Here, signal − The signal number to be invoked.Here is an example of raise() in C language, Example Live Demo#include #include void handler(int sig) { printf("Signal received : %d", sig); } int main() { signal(SIGILL, handler); printf("Sending ... Read More

403 Views
The function atexit() is used to call the function after the normal exit of program. The program is called without any parameters. The function atexit() is called after exit(). The termination function can be called anywhere in the program. This function is declared in “stdlib.h” header file.Here is the syntax of atexit() in C language, int atexit(void (*function_name)(void))Here, function_name − The function is to be called at the time of termination of program.Here is an example of atexit() in C language, Example Live Demo#include #include void func1 (void) { printf("Exit of function 1"); } void func2 (void) { ... Read More

304 Views
The function ungetc() takes a character and pushes it back to the stream so that the character could be read again.Here is the syntax of ungetc() in C language, int ungetc(int character, FILE *stream)Here, character − The character to be pushed back to stream.stream − The pointer to the file object.Here is an example of ungetc() in C language, Example#include int main() { int c; while ((c = getchar()) != '0') putchar(c); ungetc(c, stdin); c = getchar(); putchar(c); puts(""); printf("The End!"); return 0; }Outputs a b c t h 0 ... Read More

944 Views
strlen()The function strlen() is a predefined function in C language. This is declared in “string.h” header file. It is used to get the length of array or string.Here is the syntax of strlen() in C language, size_t strlen(const char *string);Here, string − The string whose length is to be calculated.Here is an example of strlen() in C language, Example Live Demo#include #include int main () { char s1[10] = "Hello"; int len ; len = strlen(s1); printf("Length of string s1 : %d", len ); return 0; }OutputLength of string s1 : 10In the above ... Read More

6K+ Views
The function memcpy() is used to copy a memory block from one location to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language. It does not check overflow.Here is the syntax of memcpy() in C language, void *memcpy(void *dest_str, const void *src_str, size_t number)Here, dest_str − Pointer to the destination array.src_str − Pointer to the source array.number − The number of bytes to be copied from source to destination.Here is an example of memcpy() in C language, Example Live Demo#include #include int main () { ... Read More

599 Views
The function memmove() is used to move the whole memory block from one position to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language.Here is the syntax of memmove() in C language, void *memmove(void *dest_str, const void *src_str, size_t number)Here, dest_str − Pointer to the destination array.src_str − Pointer to the source array.number − The number of bytes to be copied from source to destination.Here is an example of memmove() in C language, Example Live Demo#include #include int main () { char a[] = "Firststring"; ... Read More

1K+ Views
Given a string like "-27.89", we can convert it into a double value such as -27.890000. In this article, we use various approaches from C/C++ library functions to perform this string into double conversion: Using atof() Function Using strtod() Function Using stod() Function Using stringstream() Function String to Double Conversion Using atof() Function You can use atof() function of C library that accepts the parameter of string value to convert the string into a double. Example In this example, we illustrate atof() to convert string into double. #include #include int main() { ... Read More

411 Views
The function strtod() is used to convert the string to a floating point number. The string is converted into double type number. It returns the converted number, if successful otherwise, zero. This is declared in “stdlib.h” header file.Here is the syntax of strtod() in C language, double strtod(const char *string, char **endpointer);Here, string − The string to be converted.endpointer − The pointer of already allocated object and its value is set to the next character by the function after the numeric value.Here is an example of strtod() in C language, Example Live Demo#include #include int main () { ... Read More