配置环境:Win 11 + MinGW-w64的gcc工具 + vscode调试插件。
程序很简单,就是用C语言把一个文件内容读进来然后打印输出。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char data_buffer[4096];
unsigned int buffer_length = 0;
char read_in()
{
FILE* file = fopen("majors.txt","r");
for(char* data_buffer_end = data_buffer; !feof(file);data_buffer_end++)
{
*data_buffer_end = fgetc(file);
buffer_length++;
}
fclose(file);
puts(data_buffer);
return 0;
}
int main()
{
char buffer[8192];
system("echo read in");
if(read_in())
{
printf("\033[1;31m 31Error at line %i\033[0m\n", __LINE__);
puts(strerror(errno));
puts("");
puts("");
puts("");
exit(errno);
}
return 0;
}
majors.txt文件内容:
Name: Computer Science and Technology
Introduction: Focuses on the study of computer systems, software development, and applications, including algorithms, data structures, operating systems, and database systems.
Name: Electrical Engineering
Introduction: Deals with the design, development, testing, and production of electronic devices, including circuits, signal processing, and microelectronics.
Name: Mechanical Engineering
Introduction: Studies the design, manufacturing, and maintenance of mechanical systems, including dynamics, thermodynamics, and materials science.
Name: Civil Engineering
Introduction: Involves the planning, design, construction, and maintenance of infrastructure, such as bridges, roads, and dams.
Name: Biotechnology
Introduction: Uses biological principles to develop new products, such as pharmaceuticals, vaccines, and gene-editing technologies.
Name: Finance
Introduction: Studies financial markets, investments, banking operations, risk management, and other economic activities.
Name: Law
Introduction: Focuses on the study of laws, legal systems, and the application of legal principles in society.
Name: Medicine
Introduction: The study and practice of the diagnosis, treatment, and prevention of diseases, injuries, and other physical and mental impairments.
Name: Chemical Engineering
Introduction: Involves the design, development, and operation of processes that use chemicals, materials, and energy to create new products or improve existing ones.
Name: Economics
Introduction: The study of how societies allocate resources, the production, distribution, and consumption of goods and services.
Name: Psychology
Introduction: The scientific study of the human mind and behavior, including cognitive, emotional, and social aspects.
Name: Environmental Science
Introduction: The study of the environment and the physical, chemical, and biological processes that occur in it, with a focus on solving environmental problems.
Name: Data Science
Introduction: A field that uses scientific methods, processes, algorithms, and systems to extract knowledge and insights from data.
Name: Information Technology
Introduction: Focuses on the use of computers to store, retrieve, transmit, and process data, and to support business and organizational functions.
Name: Marketing
Introduction: The study of promoting and selling products or services, including market research, advertising, and customer relationship management.
Name: Accounting
Introduction: The measurement, processing, and communication of financial information about economic entities, including the preparation of financial statements.
VSCode终端里面运行结果

用外部终端(包括cmd合powershell)都是正常的。
这会是出了什么问题啊。查资料都不知道查什么关键词