Linux c strcpy应包含在什么头文件
4个回答
展开全部
string.h
原型声明:extern char *strcpy(char *dest,char *src);
头文件:string.h
功能:把src所指由NULL结束的字符串复制到dest所指的数组中。
说明:src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。
返回指向dest的指针
有些时候自己baidu下比在这里等回答快的多哦,
还有个办法就是用man strcpy命令,会告诉你应该加什么头文件。
原型声明:extern char *strcpy(char *dest,char *src);
头文件:string.h
功能:把src所指由NULL结束的字符串复制到dest所指的数组中。
说明:src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。
返回指向dest的指针
有些时候自己baidu下比在这里等回答快的多哦,
还有个办法就是用man strcpy命令,会告诉你应该加什么头文件。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
NAME
strcpy, strncpy - copy a string
SYNOPSIS
#include <string.h>
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t n);
DESCRIPTION
The strcpy() function copies the string pointed to by src, including
the terminating null byte ('\0'), to the buffer pointed to by dest.
The strings may not overlap, and the destination string dest must be
large enough to receive the copy.
The strncpy() function is similar, except that at most n bytes of src
are copied. Warning: If there is no null byte among the first n bytes
of src, the string placed in dest will not be null terminated.
If the length of src is less than n, strncpy() pads the remainder of
dest with null bytes.
A simple implementation of strncpy() might be:
char*
strncpy(char *dest, const char *src, size_t n){
size_t i;
for (i = 0 ; i < n && src[i] != '\0' ; i++)
dest[i] = src[i];
for ( ; i < n ; i++)
dest[i] = '\0';
return dest;
}
RETURN VALUE
The strcpy() and strncpy() functions return a pointer to the destina‐
tion string dest.
简单地说,就是把第二个参数的字符串复制到第一个参数里面。而strncpy还可以指定长度。函数返回一个指向复制后字符串的指针。
strcpy, strncpy - copy a string
SYNOPSIS
#include <string.h>
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t n);
DESCRIPTION
The strcpy() function copies the string pointed to by src, including
the terminating null byte ('\0'), to the buffer pointed to by dest.
The strings may not overlap, and the destination string dest must be
large enough to receive the copy.
The strncpy() function is similar, except that at most n bytes of src
are copied. Warning: If there is no null byte among the first n bytes
of src, the string placed in dest will not be null terminated.
If the length of src is less than n, strncpy() pads the remainder of
dest with null bytes.
A simple implementation of strncpy() might be:
char*
strncpy(char *dest, const char *src, size_t n){
size_t i;
for (i = 0 ; i < n && src[i] != '\0' ; i++)
dest[i] = src[i];
for ( ; i < n ; i++)
dest[i] = '\0';
return dest;
}
RETURN VALUE
The strcpy() and strncpy() functions return a pointer to the destina‐
tion string dest.
简单地说,就是把第二个参数的字符串复制到第一个参数里面。而strncpy还可以指定长度。函数返回一个指向复制后字符串的指针。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
和windows下一样的 都是string.h
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
string.h
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询