C语言文件处理

文件写入

基础示例

核心代码:

fprintf(fp, "hello c file!\n");

完整代码:

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 以只写方式打开文件
    fp = fopen("test.txt", "w"); // r w a r+ w+ a+

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }
    printf("open success!\n");

    // 写入文件
    fprintf(fp, "hello c file!\n");

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

fprintf按照指定格式写入文件

核心代码:

int i = 33;
char c[] = "zhangdapeng";
double d = 33.33;
fprintf(fp, "%d %s %lg\n", i, c, d);

完整代码:

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 以只写方式打开文件
    fp = fopen("test.txt", "w"); // r w a r+ w+ a+

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }
    printf("open success!\n");

    // 写入文件
    int i = 33;
    char c[] = "zhangdapeng";
    double d = 33.33;
    fprintf(fp, "%d %s %lg\n", i, c, d);

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

练习:读写格式字符

需求:

  • 将int类型,字符串类型,double类型的三个变量的值按照空格分割写入到test.txt文件中
  • 读取test.txt中的一行文本,然后转换为int类型,字符串类型和double类型的变量并输出

编写write.c,实现格式化写入的功能代码:

#include <stdio.h>

int main(){
    FILE *fp = NULL;

    fp = fopen("test.txt", "w");
    if (fp == NULL){
        printf("open failed!\n");
        return -1;
    }
    printf("open success!\n");

    int age = 33;
    char name[] = "zhangdapeng";
    double weight = 83.7;
    fprintf(fp, "%d %s %lg\n", age, name, weight);

    fclose(fp);
    fp = NULL;

    return 0;
}

使用gcc编译:

gcc write.c -o write

执行:

./write

查看当前目录:

ls

查看文件内容:

cat test.txt

输出:

33 zhangdapeng 83.7

编写read.c,实现读取格式化字符的功能。

#include <stdio.h>

int main(){
    FILE *fp = NULL;

    fp = fopen("test.txt", "r");
    if (fp == NULL){
        printf("open failed!\n");
        return -1;
    }
    printf("read the test.txt success!\n");

    int newAge;
    char newName[128];
    double newWeight;

    fscanf(fp, "%d %s %lg\n", &newAge, newName, &newWeight);
    printf("newAge = %d, newName = %s, newWeight = %f\n", newAge, newName, newWeight);

    fclose(fp);
    fp = NULL;

    printf("read the format string success!\n");

    return 0;
}

编译代码:

gcc read.c -o read

执行代码:

./read

输出:

read the test.txt success!
newAge = 33, newName = zhangdapeng, newWeight = 83.700000
read the format string success!

标准输出

stdin标准输入,stdout标准输出,stderr标准错误输出。

核心代码:

fprintf(stdout, "%d %s %lg\n", i, c, d);

示例代码:

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "r"); // r w a r+ w+ a+

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open test.txt failed!\n");
        return -1;
    }

    // 读取文件
    int i;
    char c[128];
    double d;
    fscanf(fp, "%d %s %lg\n", &i, c, &d);

    // 输出
    fprintf(stdout, "%d %s %lg\n", i, c, d);

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

输出:

33 zhangdapeng 33.33

fputc每次写一个字符

示例代码:

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "a");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open test.txt failed!\n");
        return -1;
    }

    // 每次写一个字符
    fputc('a', fp);
    fputc('b', fp);
    fputc('c', fp);

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

fputs写入字符串到文件

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "w");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }

    // 写入字符串
    fputs("abc1\n", fp);
    fputs("abc2\n", fp);
    fputs("abc3\n", fp);

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

fwrite按块写入文件

这个方法非常适合处理大文件。如果要写入大型文件,优先考虑使用此方法。

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "w");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }


    // 写入文件
    char buf[] = "abc";
    int count = fwrite(buf, 1, sizeof(buf), fp);
    printf("写入了%d个字节的数据\n", count);

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

fwrite写入结构体数组

#include <stdio.h>

typedef struct person {
    int id;
    char name[32];
} Person;

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "w");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }


    // 结构体数组
    Person arr[] = {
            {1, "张三"},
            {2, "李四"},
            {3, "王五"},
    };

    // 写入文件
    int count = fwrite(arr, 1, sizeof(arr), fp);
    printf("写入了%d个字节的数据\n", count);

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

文件读取

打开模式

  • r:只读
  • w:只写
  • a:追加
  • r+:可读可写,但是不会创建文件
  • w+:可读可写,不存在则创建
  • a+:追加,不存在会创建文件
  • rb:读二进制文件
  • wb:写二进制文件

一个程序,默认最多只能打开1024个文件。

基础示例

示例代码:

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 以只写方式打开文件
    fp = fopen("test.txt", "w"); // r w a r+ w+ a+

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }
    printf("open success!\n");

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

输出:

open success!

fscanf 按照指定格式读取文件

核心代码:

int i;
char c[128];
double d;
fscanf(fp, "%d %s %lg\n", &i, c, &d);

完整代码:

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "r"); // r w a r+ w+ a+

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }
    printf("open success!\n");

    // 读取文件
    int i;
    char c[128];
    double d;
    fscanf(fp, "%d %s %lg\n", &i, c, &d);

    // 查看
    printf("读取结果:i=%d c=%s d=%lg\n", i, c, d);

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

输出:

open success!
读取结果:i=33 c=zhangdapeng d=33.33

fgetc每次读取一个字符

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "r");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open test.txt failed!\n");
        return -1;
    }

    // 每次读一个字符
    while (1) {
        char c = fgetc(fp);
        if (c == -1) {
            break;
        }
        printf("%c", c);
    };
    printf("\n");

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

feof判断文件末尾

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "r");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open test.txt failed!\n");
        return -1;
    }

    // 每次读一个字符
    char c;
    while (!feof(fp)) { // 使用feof判断文件末尾
        c = fgetc(fp);
        if (c > 0) {
            printf("%c", c);
        }
    };
    printf("\n");

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

fgets按行读取文件

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "r");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }

    // 按行读取字符串
    char buf[1024];

    // 读第1行
    fgets(buf, 1024, fp);
    printf("%s", buf);

    // 读第2行
    fgets(buf, 1024, fp);
    printf("%s", buf);

    // 读第3行
    fgets(buf, 1024, fp);
    printf("%s", buf);


    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

fgets按行循环读取文件

fgets读取到文件末尾或者读取失败的时候,返回NULL,可以以此作为循环退出的条件。

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "r");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }

    // 按行读取字符串
    char *p = NULL;
    char buf[1024];

    // 循环读取
    while (1) {
        p = fgets(buf, sizeof(buf), fp);
        if (p == NULL) {
            break;
        }
        printf("%s", buf);
    }

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

fread按块读取文件

fread一般和fwrite配合使用,适合处理大型文件。

我们可以把上个案例写入的结构体数组读取出来。

#include <stdio.h>
#include <string.h>

typedef struct person {
    int id;
    char name[32];
} Person;

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "r");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }


    // 结构体数组
    Person arr[3];

    // 初始化内存
    memset(arr, 0, sizeof(arr));

    // 读取文件
    for (int i = 0; i < 3; ++i) {
        int count = fread(&arr[i], 1, sizeof(Person), fp);
        printf("写入了%d个字节的数据\n", count);
        printf("id=%d name=%s\n", arr[i].id, arr[i].name);
    }

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

输出:

写入了36个字节的数据
id=1 name=张三
写入了36个字节的数据
id=2 name=李四
写入了36个字节的数据
id=3 name=王五

fread一次性读取文件

#include <stdio.h>
#include <string.h>

typedef struct person {
    int id;
    char name[32];
} Person;

int main() {
    // 文件类型的指针
    FILE *fp = NULL;

    // 打开文件
    fp = fopen("test.txt", "r");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }


    // 结构体数组
    Person arr[3];

    // 初始化内存
    memset(arr, 0, sizeof(arr));

    // 一次性读取文件
    fread(arr, 1, sizeof(arr), fp);

    // 读取文件
    for (int i = 0; i < 3; ++i) {
        printf("id=%d name=%s\n", arr[i].id, arr[i].name);
    }

    // 关闭文件
    fclose(fp);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

输出:

id=1 name=张三
id=2 name=李四
id=3 name=王五

文件复制

基础示例

需求:将test.txt中的内容读取并写入到test2.txt中。

核心代码:

// 读取文件
int i;
char c[128];
double d;
fscanf(fp, "%d %s %lg\n", &i, c, &d);

// 写入
fprintf(fp2,"%d %s %lg\n", i, c, d);

完整代码:

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;
    FILE *fp2 = NULL;

    // 打开文件
    fp = fopen("test.txt", "r"); // r w a r+ w+ a+
    fp2 = fopen("test2.txt", "w");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open test.txt failed!\n");
        return -1;
    }
    if (fp2 == NULL) {
        printf("open test2.txt failed!\n");
        return -1;
    }

    // 读取文件
    int i;
    char c[128];
    double d;
    fscanf(fp, "%d %s %lg\n", &i, c, &d);

    // 写入
    fprintf(fp2,"%d %s %lg\n", i, c, d);

    // 关闭文件
    fclose(fp);
    fclose(fp2);

    // 置空,释放内存
    fp = NULL;
    fp2 = NULL;

    return 0;
}

fgetc和fputc

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;
    FILE *fpw = NULL;

    // 打开文件
    fp = fopen("test.txt", "r");
    fpw = fopen("test2.txt", "w");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open test.txt failed!\n");
        return -1;
    }
    if (fpw == NULL) {
        printf("open test2.txt failed!\n");
        return -1;
    }

    char c;
    while (!feof(fp)) { // 使用feof判断文件末尾
        // 每次读一个字符
        c = fgetc(fp);
        if (c > 0) {
            // 每次写一个字符
            fputc(c, fpw);
        }
    };

    // 关闭文件
    fclose(fp);
    fclose(fpw);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

feof 判断文件末尾

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;
    FILE *fpw = NULL;

    // 打开文件
    fp = fopen("python.png", "rb");
    fpw = fopen("python2.png", "wb");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open python.png failed!\n");
        return -1;
    }
    if (fpw == NULL) {
        printf("open python2.png failed!\n");
        return -1;
    }

    char c;
    while (!feof(fp)) { // 使用feof判断文件末尾
        // 每次读一个字符
        c = fgetc(fp);
        // 每次写一个字符
        fputc(c, fpw);
    };

    // 关闭文件
    fclose(fp);
    fclose(fpw);

    // 置空,释放内存
    fp = NULL;

    return 0;
}

fgets和fputs

fgets和fputs读写文件效率更高,但是不能读写二进制文件,只能对文本文件有效。

#include <stdio.h>

int main() {
    // 文件类型的指针
    FILE *fp = NULL;
    FILE *fpw = NULL;

    // 打开文件
    fp = fopen("test.txt", "r");
    fpw = fopen("test2.txt", "w");

    // 判断是否打开成功
    if (fp == NULL) {
        printf("open failed!\n");
        return -1;
    }
    if (fpw == NULL) {
        printf("open failed!\n");
        return -1;
    }

    // 按行读取字符串
    char *p = NULL;
    char buf[1024];

    // 循环读取
    while (1) {
        p = fgets(buf, sizeof(buf), fp);
        if (p == NULL) {
            break;
        }
        fputs(buf, fpw);
    }

    // 关闭文件
    fclose(fp);
    fclose(fpw);

    // 置空,释放内存
    fp = NULL;
    fpw = NULL;

    return 0;
}

练习:读写英语

每个练习可以独立为一个c文件,也可以合并

  • 1、向english.txt中写入你最熟悉的四个英语语句,每行一个语句。
  • 2、将english.txt中的内容编写代码复制到english2.txt中。
  • 3、将english2.txt中的内容读取输出到stdout标准输出流中。

示例1:写入英语

#include <stdio.h>

int main(){
    FILE* fp = fopen("english.txt", "w+");
    if (fp == NULL){
        printf("open the english.txt fail!\n");
        return -1;
    }
    printf("open the english.txt success!\n");

    fprintf(fp, "Hi, nice to meet you!\n");
    fprintf(fp, "I like english.\n");
    fprintf(fp, "How about you?\n");
    fprintf(fp, "Do you like to play basketball?\n");

    printf("write to english.txt success!\n");

    fclose(fp);
    fp = NULL;

    return 0;
}

示例2:复制文件

#include <stdio.h>

int main(){
    FILE* r = fopen("english.txt", "r");
    if (r == NULL){
        printf("open english.txt fail!\n");
        return -1;
    }

    FILE* w = fopen("english2.txt", "w");
    if (w == NULL){
        printf("open english2.txt fail!\n");
        return -1;
    }

    char ch;
    while (1){
        ch = fgetc(r);
        if (ch == EOF){
            break;
        }
        fputc(ch, w);
    }

    printf("copy english.txt to english2.txt success!\n");

    fclose(r);
    r = NULL;

    fclose(w);
    w = NULL;

    return 0;
}

示例3:查看内容

#include <stdio.h>

int main(){
    FILE* r = fopen("english2.txt", "r");
    if (r == NULL){
        printf("open english2.txt fail!\n");
        return -1;
    }

    char ch;
    while (1){
        ch = fgetc(r);
        if (ch == EOF){
            break;
        }
        fputc(ch, stdout);
    }

    fclose(r);
    r = NULL;

    return 0;
}

标准流

stdin 标准输入流

stdin用于从键盘上读取数据,也就是从控制台读取数据,是一种特殊的文件流。

示例代码:

#include <stdio.h>

int main(){
  int n;
  fscanf(stdin, "%d", &n);
  fprintf(stdout, "%d\n", n);

  return 0;
}

输出:

11
11

stdout 标准输出流

可以将文件中读取的内容,输出到标准输出流中,也可以直接将内存中的内容输出到标准输出流中。

示例代码:

#include <stdio.h>

int main(){
    char name[] = "zhangdapeng";
    fprintf(stdout, "%s\n", name);

    return 0;
}

输出:

zhangdapeng

stderr 标准错误流

标准错误流和标准输出流的用法是一样的,不过标准错误流一般用来输出错误信息。

示例代码:

#include <stdio.h>

int main(){
    char errMsg[] = "Sorry, there is a panic error!!!";
    fprintf(stderr, "%s\n", errMsg);

    return 0;
}

输出:

Sorry, there is a panic error!!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/608158.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Java文件与IO操作

1. 文件与IO操作 1.1 文件 什么是文件: 文件,对我们并不陌生,文件是保存数据的地方,比如大家经常使用的word文档,txt文件.excel文件...都是文件。它既可以保存一张图片,也可以保持视频,声音.… 1.1.1 文件流: 1.1.2 常用的文件操作: 创建文件对象相关构造器和方法: 案例&a…

从C向C++16——常见容器2

一.stack容器 1.stack理解 概念&#xff1a; stack是一种先进后出的数据结构&#xff0c;它只有一个出口。 它在C中也叫栈&#xff0c;类似于我们在《数据结构和算法》里面的栈&#xff0c;只不过在C中把其封装成库&#xff0c;我们可以直接使用。 注意&#xff1a;栈中只有…

【因特网中自治系统内部的路由选择,RIP 进程处理 OSPFOSPF(Open Shortest Path First)最短路径优先协议】

文章目录 因特网中自治系统内部的路由选择RIP&#xff08;Routing Information Protocol&#xff09;内部网关协议RIP通告&#xff08;advertisements&#xff09;RIP: 链路失效和恢复RIP 进程处理OSPF(Open Shortest Path First)最短路径优先协议OSPF “高级” 特性(在RIP中的…

C++ 继承篇

面向对象语言的三大特性&#xff1a;封装&#xff0c;继承和多态 根据目前学到的知识&#xff0c;对于封装的理解&#xff0c;大致有两层&#xff1a; 将数据和方法封装&#xff0c;不想让外面看到用private/protected修饰&#xff0c;想让外面看到用public修饰类型的行为不满…

Mybatis 源码分析

《黑马架构师_源码系列-主流框架&中间件》-- MyBatis &#xff08;讲师&#xff1a;子慕&#xff09; * 手写持久层框架-仿写mybatis * Mybatis架构设计&主要组件 * Mybatis如何完成的初始化? * Mybatis如何完成的sql解析及执行? * Mybatis如何设置的参数? * Mybat…

容器集群管理系统Kubernetes(K8S)

目录 一、前言 1.1什么是云原生&#xff1f; 1.2云要素的四要素&#xff1f; 1.2.1微服务 1.2.2容器化 1.2.3DevOps 1.2.4持续交付 1.3云平台有哪些&#xff1f; 1.4SRE 二、Kubernetes 概述 2.1K8S 是什么 2.2K8S作用 2.3K8S版本 2.4为什么要用 K8S 2.5K8S 的特…

【论文阅读】Spectral–Spatial Attention Network for Hyperspectral Image Classification

Spectral–Spatial Attention Network for Hyperspectral Image Classification 论文地址摘要&#xff1a;1. 简介1.1.动机1.2.贡献 2. 相关作品2.1.双向递归网络RNN2.2.CNN2.3. Attention Mechanism 3. 方法3.1 Attention with RNN for Spectral Classification3.2&#xff0e…

【镜像仿真篇】磁盘镜像仿真常见错误

【镜像仿真篇】磁盘镜像仿真常见错误 记系统镜像仿真常见错误集—【蘇小沐】 1、实验环境 2023AFS39.E01&#xff08;Windows11系统镜像&#xff09;Arsenal Image Mounter&#xff0c;[v3.10.262]‍Vmware Workstation 17 Pro&#xff0c;[v17.5.1]Windows 11 专业工作站版…

单片机——直流电机

1 .关于4线直流电机 两根12v供电线&#xff0c;通入12v&#xff0c;风扇以最高转速工作。 一根测速线&#xff0c;电机工作时输出测速信号&#xff0c;提供转速反馈。一根PWM控制信号线&#xff0c;电机工作时控制器输入PWM控制信号&#xff0c;以控制风扇转速(通常为占空比可…

性能测试瓶颈:CPU 问题的深度分析和调优!

性能测试是评估系统、应用程序或服务的性能和稳定性的过程。在进行性能测试时&#xff0c;我们经常会发现一些瓶颈&#xff0c;其中之一就是与CPU相关的问题。CPU是计算机系统中最重要的组件之一&#xff0c;对系统的整体性能起着至关重要的作用。本文将从零开始详细介绍如何分…

【有趣的透镜】1.透镜初相识

1.透镜的外形和材料 (1)透镜由玻璃或者塑料制成&#xff1b; (2)透镜一般为圆型&#xff0c;其单面或双面为球面&#xff1b; 2.透镜的类型和折射 (1)球面外凸为凸透镜(聚光)&#xff0c;球面内凹为凹透镜(散光)&#xff1b; (2)透镜是基于光的折射&#xff0c;只要光从一…

第一批00后已经开始做家政了!2024年轻人的机会在哪里?2024创业小项目。

当代年轻人的路子到底有多野&#xff1f;江苏无锡的00后女生冯佳佳&#xff0c;觉得未来家政行业很有前景&#xff0c;便毅然决然的辞去了幼儿园老师的工作&#xff0c;和男朋友一起成立了家政公司。、 诚然&#xff0c;现在的家政收费是及其昂贵赚钱的&#xff0c;开锁师傅开一…

点击导航栏选项后,导航栏高亮该选项

如图所示&#xff0c;点击“流浪猫客栈”时&#xff0c;会一直高亮显示&#xff0c;表示现在看的是这个选项的页面。 Cat.jsp上写&#xff1a; <!--header--> <jsp:include page"header.jsp"><jsp:param name"flag" value"3">…

上位机图像处理和嵌入式模块部署(树莓派4b和c++新版本的问题)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 自己读书的时候是03年&#xff0c;学习c也是差不多04年开始&#xff0c;到现在基本上20年了。这20年过程当中&#xff0c;其实c的语言版本一直是在…

SSRF漏洞学习

1.ssrf漏洞简介 ssrf&#xff08;服务器端请求伪造&#xff09;&#xff0c;它是由攻击者构造形成的由服务端发起的一个较为安全的漏洞。 它攻击的目标是从外网无法访问的内部系统&#xff0c;因为它是从服务端发起的&#xff0c;所以它能够请求到与它相连并且与外网隔离的内部…

PXE批量部署,一键安装配置多台Linux系统

目录 一、PXE批量部署的优点 二、搭建PXE远程安装服务器 1. 实验初始化设置 2. 一键安装软件包 3. 复制 vmlinuz、initrd.img、pxelinux.0文件 4. 配置PE启动菜单配置文件 5. 修改配置文件&#xff0c; 启动各个软件服务 6. kickstart自动应答文件修改启动菜单配置文件…

【用文本生成歌声】Learn2Sing 2.0——歌声转换算法即梅尔频谱详解

一. 频谱图与梅尔谱图的介绍 频谱图&#xff1a;频谱图可以理解为一堆垂直堆叠在一起的快速傅里叶变换结果。 1.1 信号 在进入频谱图模块之前&#xff0c;首先我们需要了解信号是什么。 信号就是某一特定量随时间变化&#xff0c;对于音频来说&#xff0c;这个特定的变化量就…

java.net.SocketInputStream.socketRead0 卡死导致 tomcat 线程池打满的问题

0 TL;DR; 问题与原因&#xff1a;某些特定条件下 java.net.SocketInputStream.socketRead0 方法会卡死&#xff0c;导致运行线程一直被占用导致泄露采用的方案&#xff1a;使用监控线程异步监控卡死事件&#xff0c;如果发生直接关闭网络连接释放链接以及对应的线程 1. 问题 …

pytest教程-42-钩子函数-pytest_runtest_makereport

领取资料&#xff0c;咨询答疑&#xff0c;请➕wei: June__Go 上一小节我们学习了pytest_runtest_teardown钩子函数的使用方法&#xff0c;本小节我们讲解一下pytest_runtest_makereport钩子函数的使用方法。 pytest_runtest_makereport 钩子函数在 pytest 为每个测试生成报…
最新文章