帮我写一个遍历C++程序的函数并把函数提取到TXT文件中的程序
时间: 2023-03-13 19:55:01 浏览: 84
我可以给你一个例子,可以帮助你实现这个功能:#include <stdio.h>
int main()
{
FILE *fp;
char c;
// Opening file in read mode
fp = fopen("test.txt", "r");
// Check if file exists
if (fp == NULL)
{
printf("Error Opening File");
return 0;
}
// Extracting characters from file and store in c
while ((c = getc(fp)) != EOF)
{
printf("%c", c);
}
// Closing the file
fclose(fp);
return 0;
}
阅读全文