Category:C Drivers

From ElectroDragon Wiki
Revision as of 19:21, 21 November 2019 by Chao (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Header text category Header text Header text
memcmp string.h 函数memcmp用于比较字符串s1与s2的前size个字符。如果两上字符块相同,memcmp将返回0。 效率更好
strcmp string.h 比较字符串 直到 /0 Example
strncmp string.h strncmp函数是指定比较size个字符。也就是说,如果字符串s1与s2的前size个字符相同,函数返回值为0。 Example
memcpy string.h Example Example
itoa stdlib.h int 转换成二进制
printf string.h


memcpy

  • 字符串 -> 字符组, 作用:将s中的字符串复制到字符数组d中。
//memcpy.c
#include<stdio.h>
#include<string.h>
intmain() {
	char*s="Golden Global View";
	chard[20];
	clrscr();
	memcpy(d,s,strlen(s));
	d[strlen(s)]='\0';//因为从d[0]开始复制,总长度为strlen(s),d[strlen(s)]置为结束符
	printf("%s",d);
	getchar();
	return0;
}
  • 输出结果:GoldenGlobal View


REF

This category currently contains no pages or media.