Passing string arguments to Function in C programming. Functions are used to divide a large program into sub-programs for easy control. All these sub-programs are called sub-functions of the program.
#include<stdio.h>
#include<conio.h>
void fun(int, int); //defining function with parameter.
void fun2(int, int, char); //defining function with parameter.
void main()
{
fun(5, 6); //calling and passing argument to parameter.
fun2(3, 65, 'C'); //calling and passing argument to parameter.
getch();
}
void fun(int i, int j) //passing argument here to parameter.
{ //printing passed values.
printf("The Passed Integer value is: %d\n", i);
printf("The Passed Integer value is: %d\n", j);
}
void fun2(int x, int y, char z) //passing argument here to parameter.
{ //printing passed values.
printf("The Passed Integer value is: %d\n", x);
printf("The Passed Integer value is: %d\n", y);
printf("The passed Character value is: %c\n", z);
}
#include<stdio.h>
#include<conio.h>
#include<string> //including Library for Working with String.
void fun(int, string); //defining function with parameter.
void fun2(int, int, char); //defining function with parameter.
void main()
{
fun(5, "HiLaLs"); //calling and passing argument to parameter.
fun2(3, 65, 'C'); //calling and passing argument to parameter.
getch();
}
void fun(int i, string j) //passing argument here to parameter.
{ //printing passed values.
printf("The Passed Integer value is: %d\n", i);
printf("The Passed String value is: %s\n", j);
}
void fun2(int x, int y, char z) //passing argument here to parameter.
{ //printing passed values.
printf("The Passed Integer value is: %d\n", x);
printf("The Passed Integer value is: %d\n", y);
printf("The passed Character value is: %c\n", z);
}