Found 1401 Articles for C

mbrtowc() function in C/C++ program

Sunidhi Bansal
Updated on 17-Apr-2020 12:04:58

101 Views

In this article we will be discussing the working, syntax and examples of std::mbrtowc() function in C++ STL.What is std::mbrtowc()?std::mbrtowc() function is an inbuilt function in C++ STL, which is defined in the header file. mbrtowc() means that it converts the narrow multibyte character string to wide character. This function is used to convert a narrow multibyte character to wide character representation.Syntaxsize_t mbrtowc( wchar_t* pwc, char* str, size_t n, mbstate_t* ps);ParametersThe function accepts following parameter(s) −pwc − This is the pointer to the location we want the output to be stored.str − Character string which is used as the ... Read More

putwchar() function in C/C++

Sunidhi Bansal
Updated on 17-Apr-2020 09:58:18

56 Views

In this article we will be discussing the working, syntax and examples of putwchar() function in C++ STL.What is putwchar()?putwchar() function is an inbuilt function in C++ STL, which is defined in the header file. putwchar() function is used to write the wide character on the standard output device. This function takes the wide character from the arguments and writes it on the stdout or standard output of the system.This function is a wide character version of putchar() which is defined in the header file.Syntaxputwchar( wchar_t widec );ParametersThe function accepts following parameter(s) −widec − The wide character which ... Read More

mbrtoc32() in C/C++ with Examples

Sunidhi Bansal
Updated on 17-Apr-2020 09:54:48

125 Views

In this article we will be discussing the working, syntax and examples of std::mbrtoc32() function in C++ STL.What is std::mbrtoc32()?std::mbrtoc32() function is an inbuilt function in C++ STL, which is defined in header file. This function is used to convert a narrow multibyte character to UTF-32-character representation.If the associated character pointer is not null, and all other parameters are also accepted then it will convert the corresponding 32-bit character.Syntaxsize_t mbrtoc32( char32_t* pc32, char* str, size_t n, mbstate_t* ps);ParametersThe function accepts following parameter(s) −pc32 − This is the pointer to the location we want the output to be stored.str − ... Read More

mbrtoc16() in C/C++ with Examples

Sunidhi Bansal
Updated on 17-Apr-2020 09:52:41

197 Views

In this article we will be discussing the working, syntax and examples of std::mbrtoc16() function in C++ STL.What is std::mbrtoc16()?std::mbrtoc16() function is an inbuilt function in C++ STL, which is defined in header file. This function is used to convert a narrow multibyte character to UTF-16-character representation.If the associated character pointer is not null, and all other parameters are also accepted then it will convert the corresponding 16-bit character.Syntaxsize_t mbrtoc16( char16_t* pc16, char* str, size_t n, mbstate_t* ps);ParametersThe function accepts following parameter(s) −pc16 − This is the pointer to the location we want the output to be stored.str − ... Read More

mbsrtowcs() function in C/C++

Sunidhi Bansal
Updated on 17-Apr-2020 09:35:08

100 Views

In this article we will be discussing the working, syntax and examples of std::mbsrtowcs() function in C++ STL.What is std::mbsrtowcs()?std::mbsrtowcs() function is an inbuilt function in C++ STL, which is defined in the header file. mbsrtowcs() means that it converts the null terminated multibyte character string whose first byte is *src to its wide character representation. This function returns the value according to the conversion.Syntaxsize_t mbsrtowcs( wchar_t* pwc, char** str, size_t n, mbstate_t* ps);ParametersThe function accepts following parameter(s) −pwc − This is the pointer to the location we want the output to be stored.str − Character string which is ... Read More

memcpy() in C/C++

Sunidhi Bansal
Updated on 17-Apr-2020 09:30:22

3K+ Views

In this article we will be discussing the working, syntax and examples of memcpy() function in C++ STL.What is memcpy()?memcpy() function is an inbuilt function in C++ STL, which is defined in header file. memcpy() function is used to copy blocks of memory. This function is used to copy the number of values from one memory location to another.The result of the function is a binary copy of the data. This function doesn’t check for any terminating source or any terminating null character, it just copies the num bytes from the source.Examplevoid memcpy( void* destination, void* source, size_t num);ParametersThe ... Read More

Iseek() in C/C++ to read the alternate nth byte and write it in another file

Ayush Gupta
Updated on 01-Apr-2020 06:38:41

526 Views

In this tutorial, we will be discussing a program to understand how to read the alternate nth byte and write it in another file.For this, we will be provided with two .txt files. Our task is to write the contents from one file to another file using Iseek() which is used to change the pointer of the file descriptor.Example#include #include #include #include void func(char arr[], int n){    int f_write = open("start.txt", O_RDONLY);    int f_read = open("end.txt", O_WRONLY);    int count = 0;    while (read(f_write, arr, 1)){       if (count < n) ... Read More

Loops in C and C++

Ayush Gupta
Updated on 01-Apr-2020 06:36:06

214 Views

In this tutorial, we will be discussing a program to understand loops in C and C++.Looping in programming is used when we have to execute a given block code again and again. It takes in the approach for writing the same code line again and again and promoted DRY code practice.ExampleFor loop Live Demo#include using namespace std; int main(){    for (int i = 1; i

Integer literal in C/C++ (Prefixes and Suffixes)

Ayush Gupta
Updated on 01-Apr-2020 06:29:25

1K+ Views

In this tutorial, we will be discussing a program to understand integer literal in C/C++ (Prefixes and suffixes).Integer literals are literals for integer values directly represented in the source code. Further, they are of two types −Prefixes − Prefixes denotes the base of the value. For example, 0x10 indicates hexadecimal value with 0x.Suffixes − Suffixes denotes the type of the value. For example, 8465484156155LL denotes a long long integer.Example Live Demo#include using namespace std; int main(){    //prefixes    cout

INT_MAX and INT_MIN in C/C++ and Applications

Ayush Gupta
Updated on 01-Apr-2020 06:30:53

2K+ Views

In this tutorial, we will be discussing a program to understand INT_MAX and INT_MIN in C/C++.INT_MIN and INT_MAX are macros that are defined to set the minimum and maximum value for a variable/element.Example Live Demo#include int main(){    printf("%d", INT_MAX);    printf("%d", INT_MIN);    return 0; }Output2147483647 -2147483648ApplicationCalculating MIN value in an arrayExample Live Demo#include //calculating minimum element in an array int compute_min(int arr[], int n){    int MIN = INT_MAX;    for (int i = 0; i < n; i++)    MIN = std::min(MIN, arr[i]);    std::cout

Advertisements