n C programming, "command line" primarily refers to command-line arguments

swecsaleem 4 views 8 slides Sep 15, 2025
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

n C programming, "command line" primarily refers to command-line arguments, which are values passed to a program when it's executed from the command line or terminal. This allows for dynamic input and control over program behavior without modifying the source code.


Slide Content

we can change the memory size already allocated
with the help of the function realloc. This process is
called reallocation of memory. The general statement
of reallocation of memory is :
 
ptr= realloc( ptr, newsize);
This function allocates new memory space of size
newsize to the pointer variable ptr and returns a
pointer to the first byte of the memory block. The
allocated new block may be or may not be at the same
region

int main( int argc , char* argv [ ])
{
int i ;
printf(“Number of arguments : %d“, argc );
printf(“\nName of Program : %s“, argv [0] );
for ( i = 1; i < argc ; i++ )
printf(“\nUser value %d : %s “, i , argv [ i ] );
}

Command Line Arguments
Compile the program :
c:\Tc>tcc cmdline.c
c:\Tc>cmdline welcome to c-programming
c:\Tc>Number of arguments : 4
Name of Program : c:\cmdline.exe
User value 1 : welcome
User value 2 : to
User value 3 : c-programming
File Name : cmdline.c
output

 A null pointer is any pointer assigned the
integral value 0.
For example:
char *p;
p = 0; /* make p a null pointer */
In this one case — assignment of 0 — you do not need
to cast the integral expression to the pointer type.

Null pointers are particularly useful in control-flow
statements, since the zero-valued pointer evaluates to
false, whereas all other pointer values evaluate to true.
For example, the following while loop continues iterating
until p is a null pointer:
char *p;
. . .
while (p!=0)
{
. . .
/* iterate until p is a null pointer */
. . .
}

A pointer in c which has not been initialized
is known as wild pointer.
Example:
What will be output of following c program?
void main(){
int *ptr;
printf("%u\n",ptr);
printf("%d",*ptr);
}

* Here ptr is wild pointer because it has not been
initialized.
* There is difference between the NULL pointer and
wild pointer.
> Null pointer points the base address of segment.
> while wild pointer doesn’t point any specific
memory location.

#include<stdio.h>
void showSquares(int n)
{
if(n == 0)
return;
else
showSquares(n-1);
printf(“%d “, (n*n));
}
int main()
{
showSquares(5);
}
A function
calling itself
is
Recursion
Output : 1 4 9 16 25
showSquares(5)
addition
of
function
calls
to
call-
stack
call-stack
execution
of
function
calls
in
reverse
showSquares(4)
showSquares(3)
showSquares(2)
showSquares(1)
main()
Tags