
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

662 Views
In C/C++, a null pointer is a special pointer that does not point to any valid memory location. Address 0 is used for Null Pointers because address 0 is reserved by the system, and it is guaranteed not to be used for valid data. So, when a pointer is assigned the value 0 (or nullptr), it means the pointer points to nothing. Some uses of null pointers are: To initialize a pointer variable when that pointer variable isn't assigned any valid memory address yet. To pass a null pointer to a function ... Read More

2K+ Views
The size of a file refers to the number of bytes it occupies in memory. In C, size of a file can be found by moving the file pointer to the end of the file and checking its position. The position indicates the number of bytes the file contains. The most common way to do this is by using two functions: fseek() (to move to the end) and ftell() (to get the current position, which is the size of the file). Syntax Following is the syntax is as follows: FILE *fp = fopen("file.txt", "rb"); fseek(fp, 0, SEEK_END); long size = ... Read More

458 Views
In this section we will see what are the differences between exit() and _Exit() in C and C++. In C the exit() terminates the calling process without executing the remaining code which is present after exit() function.In C++11, one new function is present called _Exit(). So what is the feature of this function? The exit() function performs some cleaning before terminating the program. It clears the connection termination, buffer flushes etc. This _Exit() function does not clean anything. If we test using atexit() method, it will not work.Let us see two examples where at first we are using exit() function, ... Read More

328 Views
In C/C++, the pointers have multiple levels, which means a pointer can point to another pointer – so the chains of indirection can go on and on. For instance, a pointer to a variable's address is stored at "*ptr" (single-level pointer) while, at "**ptr", the address of another pointer is kept (a double-level pointer), so on. This is useful in allocating memory dynamically, working with multi-dimensional arrays, and handling complicated data structures.Following is the list of different levels of pointers. Let us understand these with the help of examples: Single Level Pointer ... Read More

5K+ Views
In C/C++, every character including 'a' is stored using a specific size in memory. Most of the systems including Linux, the size of a character is 1 byte. This means that any character (like a) can occupy 1 byte(8 bits of memory). To determine how much memory is used by the character 'a', we can use the sizeof() operator. So, it returns the size in bytes of a variable or data type. Following are the list of different ways to check the Standard Size in C/C++. Using sizeof with character literal ... Read More

7K+ Views
To find the Current Working Directory (CWD) in C or C++ is like asking your program: "Hey, where am I right now?". Simply we can say that it is like a folder of your program which is present and used to operate in. We can use functions like getcwd() from unistd.h in C/C++ or filesystem::current_path() from C++17. Below are the list of the ways to achieve this. Using getcwd() in C/C++ Using filesystem in C++17 Using getcwd() Function in C/C++ In C/C++, we use the getcwd() function. This function gets ... Read More

6K+ Views
In this section, we will see how to tokenize strings in C. The C has library function for this. The C library function char *strtok(char *str, const char *delim) breaks string str into a series of tokens using the delimiter delim.Following is the declaration for strtok() function.char *strtok(char *str, const char *delim)It takes two parameters. The str - The contents of this string are modified and broken into smaller strings (tokens), and delim - This is the C string containing the delimiters. These may vary from one call to another. This function returns a pointer to the first token found ... Read More

2K+ Views
There are multiple ways to wrap your existing C or C++ functionality in Python. In this section, we are going to see how we can wrap C/C++ functionality with SWIG. Below are other options to wrap c/c++ functionality in python.Manual wrappingUsing pyrex to wrap C code.CtypesSIPBoost PythonSWIG (Simple Wrapper Interface Generator) is capable of wrapping C code with numerous other languages including Perl, Python, PHP, Ruby, Tcl, C#, Common Lisp (CLISP, Allegro, CL, UFFI, CFFI), Java, Modula-3 and OCAML. Swig also supports multiple interpreted and compiled Scheme implementations (like Guile, MzScheme, Chicken) are supported.But we will discuss its implementation with ... Read More

1K+ Views
In this program, we need to find sum of array elements using pointer arithmetic.Here we use * which denotes the value stored at the memory address and this address will remain stored in the variable. Thus “int *ptr” means, ptr is a variable which contains an address and content of the address is an integer quantity.*p means it is a pointer variable. Using this and sum() we will find out sum of the elements of array.Example Code#include void s(int* a, int len) { int i, s_of_arr = 0; for (i = 0; i

1K+ Views
4 Dimensional ArrayThe 4 dimensional array is an array of 3 dimensional arrays. Each 3 dimensional array is an array of 2 dimensional arrays and each 2 dimensional array is an array of 1 dimensional arrays. In this article, we will learn all about 4 dimensional arrays, how to create them and how to access their elements with examples in both C and C++. Syntax to Create a 4D Array Following is the syntax for declaring a 4 dimensional array in C/C++: datatype array_name[dimension1][dimension2][dimension3][dimension4]; // Example int arr[3][2][3][4]; Example of a 4 Dimensional Array The ... Read More