Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Passing Structure to function in C language

Posted on October 22, 2017September 8, 2019

Table of Contents

  • Passing Structure to function in C language
    • Related

Passing Structure to function in C language

In this article, we will discuss the concept of “passing structure” to function in C language.

A structure can be passed to any function from main or sub functions as an argument.

There are two way to pass stucture as function argument

  • passing to a function by value
  • passing to a function by reference(address)

Passing structure by value

In this case, the structure variable can be passed as argument as a normal variable(by value) to the definition of function. A “structure” represents the members of structure with their values. This structure can be accessed from called function.

Passing Structure to function in C language
Structure to function Example

Output

student id is :3
student Name is :saru
student Average is :74.599998

Passing structure by reference

In this case, the structure variable can be passed as  argument as a pointer variable (passed by refferance) to the definition of function. A structure  represents the members of structure with their values. This structure can be accessed from called function by its address(using pointer variable).

Passing Structure to function in C language
Structure to function – example

Output

student id is :13
student Name is :Jhon
student Average is :59.700001

Related post

Structure in C Language                                            Structure in C++ Language
Structure with function C++ Language  
 Structure with pointer in C Language                     Structure with pointer in C++
Function in C Language                                             Nested structure  in C access with variable   
 
Nested function  in C                                                  Nested structure in C++
 
Nested Structure in C Language


Structure with function in C Language

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes