
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

176 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

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

724 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

2K+ 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

3K+ 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

362 Views
Suppose we have the string s, we have to find the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times. So if the string is like “helloworld”, then the output will be 8.To solve this, we will follow these steps −ret := 0, define two maps m and cnt, set m[“00000”] := -1store vowels into vowels arrayfor i in range 0 to size of sx := s[i], and ok := falseincrease cnt[x] by 1, set temp := empty stringfor k in ... Read More

257 Views
In this tutorial, we will be discussing a program to understand coroutines in C/C++.Coroutines are control instructions which switch the execution control between two routines which returning any of them.Example Live Demo#include int range(int a, int b){ static long long int i; static int state = 0; switch (state){ case 0: state = 1; for (i = a; i < b; i++){ return i; //returning control case 1:; //resuming control } } state = 0; return 0; } int main(){ int i; for (; i=range(1, 5);) printf("control at main :%d", i); return 0; }Outputcontrol at main :1 control at main :2 control at main :3 control at main :4

215 Views
In this tutorial, we will be discussing a program to create a C/C++ code formatting tool with the help of clang tools.SETUPsudo apt install python sudo apt install clang-format-3.5Then we will create a python file in location where the current user has read and write permissions.Exampleimport os cpp_extensions = (".cxx", ".cpp", ".c", ".hxx", ".hh", ".cc", ".hpp") for root, dirs, files in os.walk(os.getcwd()): for file in files: if file.endswith(cpp_extensions): os.system("clang-format-3.5 -i -style=file " + root + "/" + file)Create a file formatting file in the top directory of the current user.Outputclang-format-3.5 -style=google -dump-config ... Read More

4K+ Views
Creating a folder or directory on your computer is an important task in programming. A directory is like a container that helps store and organize files. In C and C++, you often need to create directories to store data, logs, or configuration files. Creating directories makes file management easier. For example, if your program needs to store logs, it should check if a "logs" folder exists. If not, it can create the folder automatically, so you don't have to do it manually. In this article, we'll show you how to create a directory in C or C++. Creating Directories ... Read More

5K+ Views
In this tutorial, we will be discussing a program to understand core dump (segmentation fault) in C/C++.It happens due to reasons like when code tries to write on read only memory or tries to access corrupt memory location.ExampleModifying a string literalint main(){ char *str; str = "GfG"; *(str+1) = 'n'; return 0; }Accessing out of array index bounds#include using namespace std; int main(){ int arr[2]; arr[3] = 10; return 0; }Accessing an address which is freed#include #include int main(void){ int* p = malloc(8); *p = 100; free(p); *p = 110; return 0; }OutputAbnormal termination of program