Mein Ziel ist es, ein C-Programm zu schreiben, mit dem ich eine Text-Datei öffne, bearbeite und wieder schließe. Das hier ist natürlich noch nicht das Programm, wie es später aussehen wird, sondern nur das Grundgerüst. Den Quelltext habe ich von hier:
http://www.learn-programming.za.net/...c_learn10.html
Hier die Fehlermeldungen, die beim Kompilieren auftauchen:Code:#include<stdio.h> int main() { FILE *f; char buf[100]; f = fopen("test.txt","w+"); //w+ Open for reading and writing and create the file if it does not exist. If the file exists then make it blank. fprintf(f,"Hello"); fgets(buf,sizeof(buf),f); printf("%s\n",buf); fclose(f); return 0; }
Nach dem Kompilieren habe ich nun Dateien mit den folgenden Endungen:Code:> "make.exe" all -------- begin -------- avr-gcc (WinAVR 20090313) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiling C: main.c avr-gcc -c -mmcu=atmega128 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o main.c:4: warning: function declaration isn't a prototype main.c: In function 'main': main.c:7: warning: implicit declaration of function 'fopen' main.c:7: warning: assignment makes pointer from integer without a cast Linking: main.elf avr-gcc -mmcu=atmega128 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o -std=gnu99 -MMD -MP -MF .dep/main.elf.d main.o --output main.elf -Wl,-Map=main.map,--cref -lm main.o: In function `main': D:\Daten\C-Programmierung\Programme\test2/main.c:7: undefined reference to `fopen' make.exe: *** [main.elf] Error 1 > Process Exit Code: 2 > Time Taken: 00:01
.c .eep .lss .lst .map .o .sym .hex
Also mein erstes Problem: Es wurde keine .elf Datei geschaffen.
Und mein zweites: Wie starte ich nachher mein Programm? Ich habe ja nur eine .hex-Datei und keine .exe!







Zitieren

Lesezeichen