C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

Write a C program to copy structure elements from one object to another object?

0 votes
225 views
asked Jan 7, 2014 by smith Geek (15,340 points)

1 Answer

0 votes

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

struct disk

{

char co[15];

float type;

int price;

};

Struct disk d1={“SONY”,1.44,20};

Struct disk d2,d3;

strcpy(d2.co,d1.co);

d2.type=d1.type;

d2.price=d1.price;

d3=d2;

clrscr();

printf(“\n %s %g %d ”, d1.co.d1.type, d1.price);

printf(“\n %s %g %d ”, d2.co.d2.type, d2.price);

printf(“\n %s %g %d ”, d3.co.d3.type, d3.price);

getch();

}

Output:

SONY 1.44 20

SONY 1.44 20

SONY 1.44 20 

answered Jan 7, 2014 by rajesh Guru (39,140 points)

Related questions

0 votes
1 answer 22 views
0 votes
1 answer 452 views
0 votes
1 answer 461 views
0 votes
1 answer 25 views
...