CODE 1
#include<stdio.h> int main(int argc, char *argv[]) { int j; printf("%d", argv[1][0]); return 0; }
CODE 2
#include<stdio.h> int main(int argc, char **argv) { int j; printf("%d", argv[1][0]); return 0; }
CODE 1 and CODE 2 both give same output. but argument 2 of main function in CODE 1 and CODE 2 are different. Array of pointers are created above data section at compile time. argv is array of pointers. Then we should declare argument in main function as pointer to pointer to character i.e., **argv. How it is correct to declare as in CODE 1?
Related Posts:
- What does ** do in C language?
- Initialization from incompatible pointer type warning when assigning to a pointer
- char *array and char array[]
- C pointers and arrays: [Warning] assignment makes pointer from integer without a cast
- “error: assignment to expression with array type error” when I assign a struct field (C)
- Getting “conflicting types for function” in C, why?
- Getting “conflicting types for function” in C, why?
- How do I create an array of strings in C?
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- What’s wrong with my code? What is argv[1]?
- How to create an array of strings in C?
- Returning an array using C
- What is the difference between char array and char pointer in C?
- Excess elements of scalar initializer for pointer to array of ints
- How can I find the number of elements in an array?
- Array type char[] is not assignable
- Parameter name omitted error?
- C char array initialization
- Dynamic vs static array in c
- Warning: comparison of distinct pointer types
- The difference between char * and char[] [duplicate]
- Pointer to 2D arrays in C
- GCC: Array type has incomplete element type
- variably modified array at file scope in C
- How to split a string into an array in Bash?
- Arrow operator (->) usage in C
- Converting array to list in Java
- Return array in a function
- How do I determine the size of my array in C?
- What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
- Pointer Arithmetic
- What does “dereferencing” a pointer mean?
- What does “dereferencing” a pointer mean?
- How do I create an array of strings in C?
- Java Error “Exception in thread “main” java.util.InputMismatchException” On an Array program
- How to print elements in a vector c++
- TypeScript Objects as Dictionary types as in C#
- Data type not understood while creating a NumPy array
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- “Expected expression before ‘ { ‘ token”
- How to print the array?
- Are vectors passed to functions by value or by reference in C++
- How do I declare a 2d array in C++ using new?
- Does JavaScript have a method like “range()” to generate a range within the supplied bounds?
- What is the difference between const int*, const int * const, and int const *?
- Javascript Uncaught TypeError: Cannot read property ‘0’ of undefined
- Does JavaScript have a method like “range()” to generate a range within the supplied bounds?
- How do you make an array of structs in C?
- Form submission: PHP S_SESSION statements within a foreach loop
- How to split a string into an array in Bash?
- Working with a List of Lists in Java
- What is the difference between const int*, const int * const, and int const *?
- Array Size (Length) in C#
- How to convert jsonString to JSONObject in Java
- Array of arrays (Python/NumPy)
- Is there a function to copy an array in C/C++?
- Passing by reference in C
- what does “>>>” mean in java?
- How to convert List
to int[] in Java? - Why does the arrow (->) operator in C exist?
- Calculating Standard Deviation & Variance in C++
- How do I create an array of strings in C?
- Return char[]/string from a function [duplicate]
- Passing a 2D array to a C++ function
- Difference between char* and const char*?
- Javascript Uncaught TypeError: Cannot read property ‘0’ of undefined
- How to convert int[] into List
in Java? - Why am I getting “array initializer must be an initializer list or string literal”?
- What is a list in Bash?
- Correct way of looping through C++ arrays
- Is “argv[0] = name-of-executable” an accepted standard or just a common convention?
- When will the worst case of Merge Sort occur?
- In Java, how to append a string more efficiently?
- #31 expression must have integral type
- How do you pass a function as a parameter in C?
- Invalid pointer error on invoking free() after malloc in C
- Using Dynamic Memory allocation for arrays
- How to create a dynamically-allocated array of const objects, but have values assigned to them?
- expression must have integral type
- How do you pass a function as a parameter in C?
- ow to create a histogram in java
- expression must have integral type
- How do you pass a function as a parameter in C?
- C free(): invalid pointer
- what does .space do in mips?
- How do I remove an array item in TypeScript?
- Finding the length of a Character Array in C
- Return char[]/string from a function
- What does << mean in Ruby?
- C++: Expression must have a constant value when declaring array inside function
- Valgrind: Invalid read of size 1
- How to print a char array in C through printf?
- How to clear all the elements of array in C?
- Constant pointer vs Pointer to constant
- Delete 2D array C++
- Reversing a string in C
- Zero an array in C code
- Passing an array by reference in C?
- Excess elements in char array initializer error
- Warning: return from incompatible pointer type in C