Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
Copying Structures in Structures and Unions of Programming in C
3195 Views
Copying Structures 
Copying structure is directly done by assignment operator(=).

Example
strc_object_copy = strc_object;
Program
#include
struct student {
int rno;
char student_name[30];
};#include
struct student {
   int rno;
   char student_name[30];
};
void main(){
   //initialize values to structure
   struct student data = {1001,"Ramesh"};
    //copy structure value to another structure
   struct student copy_data;
   copy_data = data;
   printf("%d : %s",copy_data.rno,copy_data.student_name);
}
void main(){
   //initialize values to structure
   struct student data = {1001,"Ramesh"};
   //copy structure value to another structure
   struct student copy_data;
   copy_data = data;
   printf("%d : %s",copy_data.rno,copy_data.student_name);
}
Output 
1001 : Ramesh
Next Topics
Next lessons of current book.
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Previous Topics
Previous lessons of current book.
Structures and Unions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details