Skip to content

Tag Archives: C Array and String

Consider below two statements in C. What is the difference between the two? char s[] = "geeksquiz"; char *s = "geeksquiz"; Below are the key… Read More
Variable length arrays is a feature where we can allocate an auto array (on stack) of variable size. C supports variable sized arrays from C99… Read More
We have introduced arrays in set 1 (Introduction to arrays in C). In this post array properties in C are discussed. 1) In C, it… Read More
  An array in C/C++ or be it in any programming language is a collection of similar data items stored at contiguous memory locations and… Read More
In C, it is possible to have array of all types except following. 1) void. 2) functions. For example, below program throws compiler error int… Read More
Image a situation where we want to use or print a long long string in C or C++, how to do this? In C/C++, we… Read More
This post is an extension of How to dynamically allocate a 2D array in C? A one dimensional array can be easily passed as a… Read More
Following are different ways to create a 2D array on heap (or dynamically allocate a 2D array). In the following examples, we have considered ‘r‘… Read More
  Pointers are used for storing address of dynamically allocated arrays and for arrays which are passed as arguments to functions. In other contexts, arrays… Read More
The C99 standard allows variable sized arrays (see this). But, unlike the normal arrays, variable sized arrays cannot be initialized. For example, the following program… Read More
In C/C++, we can assign a struct (or class in C++ only) variable to another variable of same type. When we assign a struct variable… Read More
In C/C++, when a character array is initialized with a double quoted string and array size is not specified, compiler automatically allocates one extra space… Read More
In C/C++, initialization of a multidimensional arrays can have left most dimension as optional. Except the left most dimension, all other dimensions must be specified. For… Read More
Recursion can be used to do both tasks in one line. Below are one line implementations for stracat() and strcmp(). /* my_strcat(dest, src) copies data… Read More
Consider the below program. #include<stdio.h> void fun(int arr[])   {   int i;         /* sizeof should not be used here to get number      of elements in… Read More