我工作的一個程序下覆盆子PI的發展,我已經得到這個奇怪的錯誤。無法打開2 FILE *
老實說,我有關於它的起源毫無頭緒。該計劃迄今爲止非常簡單。
#include <bcm2835.h>
#include <time.h>
#include <sys/time.h>
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>
int main(int argc, char *argv[])
{
FILE *file;
FILE *file2;
FILE *peak1;
FILE *peak2;
file = fopen("input0.txt", "a+");
file2 = fopen("input1.txt", "a+");
peak1=fopen("peak1.txt", "a+");
peak2=fopen("peak2.txt", "a+");
fprintf(file, "%s\n", "HELLO!");
fprintf(peak1, "%s\n", "HELLO!");
}
錯誤: -
當我運行程序並檢查輸出到文件,只有'input0.txt'
已"HELLO!"
寫在那裏爲'peak1.txt'
無關。
我可以寫入前兩個文件file
和file2
,但不能寫入第二個文件peak1
和peak2
。
我試圖寫多件事情,但無濟於事。可能是什麼問題呢?
謝謝!
附加已包含很多的頭文件,我不知道你的項目,但對你的代碼貼出你只需要''呀 –
,我承認這一點。我打算讓我的計劃稍後再做更多,而且我知道我將來需要這些頭文件。謝謝! – MEric
@MEric *'我爲什麼那麼可以寫信給前兩個文件(文件/文件2)如果我不要麼關閉他們'* - ?因爲它不只有經過'FCLOSE是指()'數據寫入磁盤......但是'fclose()'在關閉文件前確定。閱讀我的第一行回答 - 獲取它**?** –