gpt4 book ai didi

c - inptr 和 outptr 是什么意思

转载 作者:行者123 更新时间:2023-11-30 20:29:26 25 4
gpt4 key购买 nike

有人知道 inptr 和 outptr 是什么意思吗?我知道它是 in 和 out 指针的缩写,但我似乎无法理解它的用途?另外,如果你能告诉我为什么 FILE 也在那里,那么它也很合适。谢谢!

char *infile = argv[1]; char *outfile = argv[2];

// open input file
FILE *inptr = fopen(infile, "r");
if (inptr == NULL)
{
printf("Could not open %s.\n", infile);
return 2;
}

// open output file
FILE *outptr = fopen(outfile, "w");
if (outptr == NULL)
{
fclose(inptr);
printf("Could not create %s.\n", outfile);
return 3;
}

最佳答案

inptr 对应于您的程序正在读取的文件,outptr 对应于您的程序正在写入的文件。

大多数 C I/O 函数都采用指向 FILE 类型的指针,该类型封装了系统的 I/O channel (称为)的所有详细信息( FILE 类型的确切结构因系统而异,并且这些详细信息对您是隐藏的)。 inptroutptr 分别映射到您的输入和输出文件。

关于c - inptr 和 outptr 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58054241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com