A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C program to pass a string to a function
Q:

C program to pass a string to a function

0

C program to pass a string to a function

Given a string and we have to print the string by passing it to the user define function in C.

Here is the function that we have used in the program,

void Strfun(char *ptr)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to pass string to a function and print in C

/*  
C program to pass a string to a function
*/

#include <stdio.h>

void Strfun(char *ptr)
{
    printf("The String is : %s",ptr);
}

// main function
int main()
{
	// Declare a buffer of type "char"
	char buff[20]="Hello Function";
	
	// Passing string to Function
	Strfun(buff);
	
	return 0;
}

Output

The String is : Hello Function

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now