string.h .
char *strcat(char *s1,char *s2) | s2 s1, s1 |
char *strncpy(char*s1, char *s2, int n) | n s2 s1, s1; |
int strcmp(char *s1,char *s2) | s1 s2, 0, |
int strncmp(char *s1,char *s2, int n) | n s1 s2, 0, n |
int strlen(char *s) | s |
char *strset(char *s,char c) | s , c, s |
char *strnset(char *s,char c, int n) | n s , c, s |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char m1[80] = " ";
char m2[80] = " ";
char m3[80];
system("chcp 1251");
system("cls");
strncpy(m3, m1, 6); // '\0'
puts(" strncpy(m3, m1, 6)");
puts(m3);
strcpy(m3, m1);
puts(" strcpy(m3, m1)");
puts(m3);
puts(" strcmp(m3, m1) ");
printf("%d", strcmp(m3, m1));
strncat(m3, m2, 5);
puts(" strncat(m3, m2, 5)");
puts(m3);
strcat(m3, m2);
puts(" strcat(m3, m2)");
puts(m3);
puts(" m1 strlen(m1): ");
printf("%d\n", strlen(m1));
strnset(m3, 'f', 7);
puts(" strnset(m3, 'f', 7)");
puts(m3);
strset(m3, 'k');
puts(" strnset(m3, 'k')");
puts(m3);
getchar();
return 0;
}
, , , . , , .
, . , .
:
struct _
{
1;
2;
...
n;
};
}
.
struct date
{
int day; // 4
char *month; // 4
int year; // 4
};
, :
date 12 . , *month , .
, .
struct persone
{
char lastname[20]; //
char firstname[20]; //
struct datebd; //
};