- Trending Categories
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 7346 Articles for C++
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
7K+ Views
In this section, we will see how we can get the size of an integer array in C or C++? The size of int[] is basically counting the number of elements inside that array. To get this we can use the sizeof() operator. If the array name is passed inside the sizeof(), then it will return total size of memory blocks that are occupied by the array. Now if we divide it by the size of each element, then we can get number of elements.Let us see the following example to get the better idea about it.Example#include using namespace ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
410 Views
Here we will see how the copy constructors are implemented in C++. Before discussing that we should know what is the copy constructor.The copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously. The copy constructor is used to −Initialize one object from another of the same type.Copy an object to pass it as an argument to a function.Copy an object to return it from a function.If a copy constructor is not defined in a class, the compiler itself defines one. If the class has pointer ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
203 Views
The C library function int remove(const char *filename) deletes the given filename so that it is no longer accessible.Following is the declaration for remove() function.int remove(const char *filename)This function takes the filename. This is the C string containing the name of the file to be deleted. On success, zero is returned. On error, -1 is returned, and errno is set appropriately.Example#include #include int main () { int ret; FILE *fp; char filename[] = "file.txt"; fp = fopen(filename, "w"); fprintf(fp, "%s", "This is tutorialspoint.com"); fclose(fp); ret = remove(filename); if(ret == 0) { ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
286 Views
The C library function int rename(const char *old_filename, const char *new_filename) causes the filename referred to by old_filename to be changed to new_filenameFollowing is the declaration for rename() function.int rename(const char *old_filename, const char *new_filename)The parameters are old_filename − This is the C string containing the name of the file to be renamed and/or moved, new_filename − This is the C string containing the new name for the file.On success, zero is returned. On error, -1 is returned, and errno is set appropriately.Example#include int main () { int ret; char oldname[] = "file.txt"; char newname[] = ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
1K+ Views
Here we will see what type of operations can be performed on struct variables. Here basically one operation can be performed for struct. The operation is assignment operation. Some other operations like equality check or other are not available for stack.Example#include typedef struct { //define a structure for complex objects int real, imag; }complex; void displayComplex(complex c){ printf("(%d + %di)", c.real, c.imag); } main() { complex c1 = {5, 2}; complex c2 = {8, 6}; printf("Complex numbers are:"); displayComplex(c1); displayComplex(c2); }OutputComplex numbers are: (5 + 2i) (8 + 6i)This works fine as ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
1K+ Views
Here we will see what is the restrict keyword in C. The restrict keyword first introduced in C99 version. Let us see what is actually this restrict keyword.The restrict keyword is used for pointer declarations as a type quantifier of the pointer.This keyword does not add new functionalities. Using this the programmer can inform about an optimization that compiler can make.When the restrict keyword is used with a pointer p, then it tells the compiler, that ptr is only way to access the object pointed by this. So compiler will not add any additional checks.If the programmer uses restrict keyword ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
241 Views
Here we will see what is the __func__ C.Basically the __func__ or __FUNCTION__ (Some old versions of C and C+ + supports __func__). This macro is used to get the name of the current function.Example#include void TestFunction(){ printf("Output of __func__ is: %s", __func__ ); } main() { printf("Output of __func__ is: %s", __func__ ); TestFunction(); }OutputOutput of __func__ is: main Output of __func__ is: TestFunction
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
3K+ Views
Here we will see what are the differences between while(1) and while(0) in C or C++. The while is a loop of C or C++. Using this loop we can check one condition, and the statements inside the loop will be executed while the condition is true.The while(1) or while(any non-zero value) is used for infinite loop. There is no condition for while. As 1 or any non-zero value is present, then the condition is always true. So what are present inside the loop that will be executed forever. To come out from this infinite loop, we have to use ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
295 Views
Here we will see how the preprocessors are working in C or C++. Let us see what are the preprocessors.The preprocessors are the directives, which give instructions to the compiler to preprocess the information before actual compilation starts.All preprocessor directives begin with #, and only white-space characters may appear before a preprocessor directive on a line. Preprocessor directives are not C++ statements, so they do not end in a semicolon (;).You already have seen a #include directive in all the examples. This macro is used to include a header file into the source file.There are number of preprocessor directives supported ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
4K+ Views
Here we will see what is the meaning of volatile qualifier in C++. The volatile qualifier is applied to a variable when we declare it. It is used to tell the compiler, that the value may change at any time. These are some properties of volatile.The volatile keyword cannot remove the memory assignmentIt cannot cache the variables in register.The value cannot change in order of assignment.Let us see, how we can use the volatile keyword.volatile int a; int volatile a;Here these two declarations are correct. Like other datatypes, we can use volatile pointers, structures, unions etc. The volatile structures and ... Read More