📄 strncpy.c
字号:
/* Using the strncpy() function. */
#include <stdio.h>
#include <string.h>
char dest[] = "..........................";
char source[] = "abcdefghijklmnopqrstuvwxyz";
int main( void )
{
size_t n;
while (1)
{
puts("Enter the number of characters to copy (1-26)");
scanf("%d", &n);
if (n > 0 && n< 27)
break;
}
printf("\nBefore strncpy destination = %s", dest);
strncpy(dest, source, n);
printf("\nAfter strncpy destination = %s\n", dest);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -