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
- Arrow operator (->) usage in C
- Converting array to list in Java
- Return array in a function
- What does “dereferencing” a pointer mean?
- 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
- 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 *?
- How to split a string into an array in Bash?
- Array of arrays (Python/NumPy)
- Calculating Standard Deviation & Variance in C++
- How do I create an array of strings in C?
- Javascript Uncaught TypeError: Cannot read property ‘0’ of undefined
- How to convert int[] into List
in Java? - Correct way of looping through C++ arrays
- Is “argv[0] = name-of-executable” an accepted standard or just a common convention?
- In Java, how to append a string more efficiently?
- Using Dynamic Memory allocation for arrays
- How to create a dynamically-allocated array of const objects, but have values assigned to them?
- How do you pass a function as a parameter in C?
- 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
- 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
- How to properly malloc for array of struct in C
- C++ array assign error: invalid array assignment
- strcmp giving segmentation fault
- Typedef function pointer?
- Bubble sort algorithm in MIPS
- Convert char array to a int number in C
- How to pass 2D array (matrix) in a function in C?
- Iterate through a C array
- Using multiple variables in a for loop in Python
- char pointers: invalid conversion from ‘char*’ to ‘char’?
- How to copy a char array in C?
- type any? has no subscript members
- Why use pointers?
- struct has no member named
- What’s the difference between * and & in C?
- java.lang.ArrayIndexOutOfBoundsException: 4 Error
- IndexError: index 10 is out of bounds for axis 0 with size 10
- Initializing array of structures
- What is the difference between array and enum in C ?
- Invalid type argument of -> C structs
- Double pointer array in c++
- Can I create an Array of Char pointers in C?
- C: pointer to array of pointers to structures (allocation/deallocation issues)
- What exactly is meant by “de-referencing a NULL pointer”?
- Two-dimensional array in Swift
- How to iterate through table in Lua?
- How to sort in-place using the merge sort algorithm?
- typedef struct pointer definition
- char array not assignable
- C++ correct way to return pointer to array from function
- Realloc Invalid Pointer in C
- Array to Hash Ruby
- typedef fixed length array
- Create an empty object in JavaScript with {} or new Object()?
- C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’
- Initializing 2D char array in C
- Pointer to a string in C?
- Checking if a key exists in a JavaScript object?
- Using the Pythagorean theorem with Java
- Array of Linked Lists C++