b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

c strchr函数_strchr函数php_strchr函数功能

电脑杂谈  发布时间:2017-02-21 12:41:08  来源:网络整理

strchr函数功能_strchr函数php_c strchr函数

c strchr函数c strchr函数

C语言字符串操作函数总结

Part 1: Copying

1、 函数名: strcpy

用 法: char * strcpy ( char * destination, const char * source );

功 能: 串拷贝(Copies the C string pointed by source into the array pointed by destination, including the terminating null character. To avoid overflows, the size of the array pointed by destination shall be long enough to contain the same C string as source (including the terminating null character), and should not overlap in memory with source.)

程序例:

#include <stdio.h>

#include <string.h>

int main(void)

{

char string[10];

char *str1 = "abcdefghi";

strcpy(string, str1);

printf("%s/n", string);

return 0;

}

2、函数名: strncpy

用 法: char * strncpy ( char * destination, const char * source, size_t num );

功 能: 指定长度的串拷(Copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found before num characters have been copied, destination is padded with zeros until a total of num characters have been written to it. No null-character is implicitly appended to the end of destination, so destination will only be null-terminated if the length of the C string in source is less than num.)

程序例:

#include <stdio.h>

#include <string.h>

int main ()

{

char str1[]= "To be or not to be";

char str2[6];

strncpy (str2,str1,5);

str2[5]='/0';//no '/0' will be appendeded to the end of destination automatically

puts (str2);//输出To be

return 0;

}

另外参考:

void * memcpy ( void * destination, const void * source, size_t num );


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-33666-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 草尾毅
      草尾毅

    • 张林
      张林

      果断要找一个会踢球的老公呀~

      • 柳泽三千代
        柳泽三千代

        期待你带给我们更多更好的作品

    热点图片
    拼命载入中...