▼点击下方名片,关注公众号,获取更多精彩内容▼
欢迎关注【玩转单片机与嵌入式】公众号,回复关键字获取更多免费视频和资料
回复【加群】,【单片机】、【STM32】、【硬件知识】、【硬件设计】、【经典电路】、【论文】、【毕业设计】、【3D封装库】、【PCB】、【电容】、【TVS】、【阻抗匹配】、【资料】、【终端电阻】、【Keil】、【485】、【CAN】、【振荡器】、[USBCAN]、【PCB】、【智能手环】、【智能家居】、【智能小车】、【555】、【I2C】、【华为】、【中兴】,等……
int printf(const char *format, ...);
printf("Hello, %s!\n", "world");
int scanf(const char *format, ...);
int age;
scanf("%d", &age);
3、fprintf:将格式化的数据输出到文件。
int fprintf(FILE *stream, const char *format, ...);
int fscanf(FILE *stream, const char *format, ...);
FILE *fopen(const char *filename, const char *mode);
FILE *file = fopen("example.txt", "r");
int fclose(FILE *stream);
char *fgets(char *s, int size, FILE *stream);
int fputs(const char *s, FILE *stream);
int fgetc(FILE *stream);
int fputc(int c, FILE *stream);
void rewind(FILE *stream);
int feof(FILE *stream);
void *malloc(size_t size);
int *arr = (int *)malloc(5 * sizeof(int));
void *calloc(size_t num_elements, size_t element_size);
int *arr = (int *)calloc(5, sizeof(int));
void *realloc(void *ptr, size_t size);
arr = (int *)realloc(arr, 10 * sizeof(int));
void free(void *ptr);
free(arr);
int rand(void);
int random_number = rand();
void srand(unsigned int seed);
srand(42);
int abs(int n);
int absolute_value = abs(-5);
int atoi(const char *str);
int number = atoi("42");
double atof(const char *str);
double pi = atof("3.14159");
void exit(int status);
exit(0); // 正常退出
int system(const char *command);
system("ls -l");
void qsort(void *base, size_t num_elements, size_t element_size, int (*compare_function)(const void *, const void *));
int compare(const void *a, const void *b) {
return (*(int *)a - *(int *)b);
}
int arr[] = {5, 2, 9, 1, 5};
qsort(arr, 5, sizeof(int), compare);
char *strcpy(char *dest, const char *src);
char destination[20];
char source[] = "Hello, world!";
strcpy(destination, source);
char *strcat(char *dest, const char *src);
char str1[20] = "Hello, ";
char str2[] = "world!";
strcat(str1, str2);
3、strlen:计算字符串的长度。
size_t strlen(const char *s);
char str[] = "Hello";
size_t length = strlen(str);
int strcmp(const char *s1, const char *s2);
char str1[] = "apple";
char str2[] = "banana";
int result = strcmp(str1, str2);
int strncmp(const char *s1, const char *s2, size_t n);
char str1[] = "apple";
char str2[] = "appetizer";
int result = strncmp(str1, str2, 3);
char *strchr(const char *s, int c);
char str[] = "Hello, world!";
char *result = strchr(str, 'w');
char *strstr(const char *haystack, const char *needle);
char str[] = "The quick brown fox";
char *result = strstr(str, "brown");
char *strtok(char *str, const char *delimiters);
char str[] = "apple,banana,grape";
char *token = strtok(str, ",");
while (token != NULL) {
printf("%s\n", token);
token = strtok(NULL, ",");
}
在本公众号内回复【电路】可以获取5000个经典参考电路。
END
扫描上方二维码加群,回复【加群】或扫码加我好友,限时免费进入技术交流群。
推荐阅读
【专辑】器件选型
【专辑】单片机
【专辑】经验分享
【专辑】STM32
【专辑】硬件设计
【专辑】软件设计
【专辑】开源项目
【专辑】职业发展
感谢大家阅读,如果喜欢
请点赞和“在看”吧,或者分享到朋友圈。
点击跳转到原文,限时优惠加入我们的知识星球(加好友获取免费券)