3. Copying Arrays
int a[10] = { 3, 6, 5, … } ;
int b[10] ;
for ( i = 0 ; i <= 9 ; i++ )
b[i] = a[i] ;
struct z
{
int arr[10] ;
} ;
struct z b ;
struct z a
b = a ;
OR
= { 3, 6, 5, ... } ;
4. Nested Structures
main( )
{ struct address
{
char city[20] ;
long int pin;
} ;
struct emp
{
char n[20] ;
f - int
printf ( ”%d”, a.b.c.d.e.f ) ;
struct emp e = { ”Rahul”, 23, ”Nagpur”, 440010,
4000.50 } ;
printf ( ”%s %d%s%ld%f”, e.n,
}
e.age, e.pin,
e.s ) ;
e.city,
int age ;
struct address a ; float s ;
} ;
ee..aa..ppiinn
ee..aa..cciittyy aa..cciittyy
5. Passing Structure Elements
main( )
{
struct book
{
char n[20] ; int nop ; float pr ;
} ;
struct book b = { ”Basic”, 425, 135.00 } ;
display ( b.n, b.nop,b.pr ) ;
show } ( b.n, &b.nop, &b.pr ) ;
display ( char *n, int pg, float p )
{
} printf ( ”%s %d %f”, n, pg, p ) ;
show ( char *n, int *pg, float *p )
{
printf ( ”%s %d %f”, n, *pg, *p ) ;
}
7. main( )
{
struct com
{
float r, i ;
} ;
struct com a
struct com b = { 1.2, 1.7 } ;
struct com add ( struct com, struct com ) ;
c = add ( a, b ) ;
printf ( ”%f %f”, c.r, c.i ) ;
}
add ( struct com x, struct com y )
}
Complex Nos.
struct com c ;
struct com z ;
x.r + y.r ;
x.i + y.i ;
= { 2.5, 1.3 } ;
struct com add ( struct com x, struct com y )
{
z.= x.+ y.r ;
z.= x.+ y.i ;
return z ;
8. Applications of Structures
Database Management
Positioning Cursors
Receiving ascii and scan codes
Displaying characters
Printing on printer
Mouse Programming
Graphics Programming
All Disk Operations
etc.
9. Floppy Disks
JJaacckkeett
WWrriittee PPrrootteecctt nnoottcchh
PPllaatttteerr (( mmyyllaarr ))
HHuubb rriinngg
RReeaadd // WWrriittee sslloott
RReettrraaccttaabbllee mmeettaall sshheeaatthh
Access to magnetic surface
Access to magnetic surface
Platter ( only when retracted )
( mylar )
( only when retracted )
WWrriittee PPrrootteecctt nnoottcchh
Platter
( mylar )
10. Hard Disk
SSppiinnddllee
RReeaadd // WWrriittee HHeeaadd
HHeeaadd AAsssseemmbbllyy
PPllaatttteerr (( aalluummiinniiuumm ))
13. Logical Organization
17
18
1
2
11
10
Boot
Sector
Boot
Sector
3
6 5 4
D
F2
SSiiddee 00,, TTrraacckk 00 SSiiddee 11,, TTrraacckk 00
F1
7
11
F1
8
10
9
12
13 14 15
16
17
18
1
3
2
6 5 4
7
8
9
12
13 14 15
16
D
D
D D D
D
D
D
D
D
D D D
F1
F1
F1 F1 F1
F1
F1
F2
F2 F2 F2
F2
F2
F2
F2
14. main( )
{
Reading Boot Sector
char arr [ 512 ] ; int i ;
printf ( ”Enter floppy in drive A,
press any key …” ) ;
getch( ) ;
absread ( ) ;
0, 1, 0, arr
for ( i = 0 ; i 512 ; i++ )
printf ( ”%c”, arr [ i ] ) ;
Boot Sector 11
SSiiddee 00,, TTrraacckk 00
#include ”dos.h”
}