#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main() {
char arr1[] = "hello";
char arr2[20] = "############";
strcpy(arr2, arr1);
printf("%s\n", arr2);
printf("-------------------------------\n");
char arr3[] = "hello world";
memset(arr3, '*', 5);
printf("%s\n", arr3);
return 0;
}
hello
-------------------------------
***** world
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void Swap1(int x, int y) {
int tmp = 0;
tmp = x;
x = y;
y = tmp;
}
void Swap2(int* pa, int* pb) {
int tmp = 0;
tmp = *pa;
*pa = *pb;
*pb = tmp;
}
int main() {
int a = 10;
int b = 20;
printf("a=%d b=%d\n", a, b);
Swap1(a, b);
printf("a=%d b=%d\n", a, b);
Swap2(&a, &b);
printf("a=%d b=%d\n", a, b);
return 0;
}
a=10 b=20
a=10 b=20
a=20 b=10