.


:




:

































 

 

 

 





:

, ;

- (, printf() scanf()).

:

struct ={1, _2,..., n};

struct datebd={8,"", 1978};

. . :

.

printf("%d %s %d",bd.day, bd.month, bd.year);

-.

#include <stdio.h>
#include <stdlib.h>
struct date

{

int day;

char *month;

int year;
};
struct persone

{

char firstname[20];

char lastname[20];

struct date bd;
};
int main()

{

system("chcp 1251");

system("cls");

struct persone p;

printf(": ");

scanf("%s",p.firstname);

printf(": ");

scanf("%s",p.lastname);

printf(" \n: ");

scanf("%d",&p.bd.day);

printf(": ");

scanf("%s",p.bd.month);

printf(": ");

scanf("%d",&p.bd.year);

printf("\n : %s %s, %d %s %d ",

p.firstname, p.lastname, p.bd.day, p.bd.month, p.bd.year);

getchar(); getchar();

return 0;
}


. }. .

struct complex_type //
{

double real;

double imag;
} number; //

: number.real, number.imag.

 

, .

, , , , .

, , . , .

union
{

1;

2;

...

n;
};

:

, ;

.

#include <stdio.h>
#include <stdlib.h>
int main()

{

char temp;

system("chcp 1251");

system("cls");

union

{

unsigned char p[2];

unsigned int t;

} type;

printf(" : ");

scanf("%d", &type.t);

printf("%d = %x .\n",type.t, type.t);

//

temp = type.p[0];

type.p[0] = type.p[1];

type.p[1] = temp;

printf(" , \n");

printf("%d = %x .\n",type.t, type.t);

getchar(); getchar();

return 0;
}


 

, , .

, . ,

:

, , .

,

#include <stdio.h>
#include <stdlib.h>
#define YEAR0 1980
struct date
{

unsigned short day:5;

unsigned short month:4;

unsigned short year:7;
};
int main()

{

struct date today;

system("chcp 1251");

system("cls");

today.day =16;

today.month = 12;

today.year = 2013 - YEAR0; //today.year = 33

printf("\n %u.%u.%u \n", today.day, today.month, today.year+YEAR0);

printf("\n today: %d ", sizeof(today));

printf("\n today = %hu = %hx .", today, today)

getchar();

return 0;
}


 

.

3

#include <stdio.h>
#include <stdlib.h>
struct book
{

char title [15];

char author [15];

int value;
};
int main()

{

struct book libry[3];

int i;

system("chcp 1251");

system("cls");

for(i=0;i<3;i++)

{

printf(" %d :",i+1);

gets(libry[i].title);

printf(" %d : ",i+1);

gets(libry[i].author);

printf(" %d : ",i+1);

scanf("%d",&libry[i].value);

getchar();

}

for(i=0;i<3;i++)

{

printf("\n %d. %s ", i+1,libry[i].author);

printf("%s %d",libry[i].title,libry[i].value);

}

getchar();

return 0;
}


 

 

, . . .
(). #. , , .


#include
#define ()
#undef
#if
#ifdef
#ifndef
#else
#elif , else if
#endif
#line
#error
#pragma , .

 

#include

#include . , . , . , .

#include <stdio.h>
#include "func.c"

#define

#define .





:


: 2016-11-02; !; : 610 |


:

:

, ; , .
==> ...

1736 - | 1502 -


© 2015-2024 lektsii.org - -

: 0.018 .