C语言中常用的函数与语法示例。
共 2951字,需浏览 6分钟
·
2024-07-04 00:00
int a = 10;
float b = 3.14;
char c = 'A';
int num;
char ch = 'B';
int a = 5, b = 7;
if (a > b && b % 2 == 0) {
printf("a is greater than b and b is even.");
}
int i;
for (i = 1; i <= 10; i++) {
if (i % 2 == 0) {
printf("%d is even\n", i);
}
}
printf("format string", argument_list);
int a = 5;
float b = 3.14;
char c = 'A';
printf("a = %d, b = %f, c = %c", a, b, c);
scanf("format string", argument_list);
int a;
float b;
char c;
scanf("%d%f%c", &a, &b, &c);
strlen(string);
char str[] = "Hello, world!";
int len = strlen(str);
printf("The length of str is %d", len);
strcpy(destination, source);
char src[] = "Hello";
char dest[10];
strcpy(dest, src);
printf("The copied string is %s", dest);
strcat(destination, source);
char str1[10] = "Hello";
char str2[10] = "world";
strcat(str1, str2);
printf("The concatenated string is %s", str1);
评论