Thursday, June 12, 2014

C++ Beginners Tutorial 24 - How to pass a structure to a function in C++

2:45 PM









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <cstring>
using namespace std;

struct Books
{
char name[50];
char auther[50];
int id;
};
void printBook(struct Books book)
{
cout<<"Book 1 name: "<<book.name<<endl;
cout<<"Book 1 auther: "<<book.auther<<endl;
cout<<"Book 1 id: "<<book.id<<endl;
}
int main()
{

struct Books book1;

strcpy(book1.name,"C++ tutorials");
strcpy(book1.auther,"ProgrammingKnowledge");
book1.id=1;

printBook(book1);

return 0;
}






















--------------------------------------------------------

passing structures to functions

pass one structure to function

Searches related to How to pass a structure to a function in C++

passing an array of structures to a function in c++

passing an array of structures to a function

passing an array of structures to a function in c

pass array of structs to function

how do you return a structure from functions

how to return a struct from a function in c++

pointer in structure

pointer struct

Structure function in C++ 9 posts

Member functions inside struct








Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top