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
C Articles - Page 52 of 134
259 Views
Functions are like a machine as they perform some functionality and produces a result of some type. Like, machine takes some input, process that input and produce an output similarly, function takes some value, operates on those value and produces the output. Manually a person passes the input to the machine then only the machine will start its functionality in the same manner when the programmer calls the function it will start executing.Functions can be different in name in various languages, but they share two common characteristics like −They contain sequence of instructions that needs to be processedThose instructions are ... Read More
11K+ Views
In this article, we will be discussing the working, syntax, and examples of rand() and srand() function in C++ STL.What is rand()?rand() function is an inbuilt function in C++ STL, which is defined in header file. rand() is used to generate a series of random numbers. We use this function when we want to generate a random number in our code.Like we are making a game of ludo in C++ and we have to generate any random number between 1 and 6 so we can use rand() to generate a random number.The random number is generated by using an ... Read More
179 Views
Write a program that compiler and runs both in c and c++ and produces different results.There are multiple types of programs that give different results when compiled in c and c++.i. Using character literals− c and c++ both treat characters differently. In C, they are treated as integer literals whereas, in C++, they are treated as characters.Example Live Demo#include int main(){ printf("%d", sizeof('a')); return 0; }OutputC : 4 C++: 1ii. Use of binary number − binary values are not considered as binary in c, instead treat it as integer. But in c++, they are treated as binary.Example Live Demo#include int ... Read More
433 Views
In competitive programming, the most important thing is an effective code. Optimized and faster code is important and can make a difference in the ranks of the programmer.To write an effective c/c++ code in competitive programming, here are some effective tools for writing c/c++ code efficiently, First, let’s recall some basic terms, Template is writing code that does not depend on a particular type.Macro is a named code fragment.Vectors are like automatically resizable dynamic arrays that update size with insertion and deletion of the element.Now, let’s see some basic updates in code that can make in increasing efficiency of code, ... Read More
434 Views
A program that can interact with the operating system irrespective of the OS on which it runs.Most of the compilers of c/c++ have the power to define macros that detect OS.Some Macros of GCC compiler are −_WIN32: macros for 32 bit and 64-bit Windows OS._WIN64: macros for 64-bit Windows OS._UNIX: macros for UNIX OS._APPLE_: macros for macOS.Based on these macros defined, let’s create a program that will work irrespective of the OS −Example Live Demo#include using namespace std; int main() { #ifdef _WIN32 system("dir"); #else system("ls"); #endif ... Read More
206 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
124 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
223 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
319 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
182 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