Writing data into a txt file, C [message #1835782] |
Sat, 12 December 2020 07:03  |
Eclipse User |
|
|
|
I am trying to save data into txt file in eclipse.
However upon calling `fopen` function I get such error while building:
main.c:(.text.startup.main+0xa4): undefined reference to `fopen'
char n[] = "6E436C703186B19CBC6BFD77DFD8FF3D85F7274793A0A";
char subn[40];
strncpy ( subn, n, 5);
subn[5] = '\0';
USART_TX_String(subn);
_delay_ms(1000);
//Zapis do pliku
int num;
FILE *fptr;
fptr = fopen("hexnumbers.txt","w");
if(fptr == NULL)
{
printf("Error!");
exit(1);
}
printf("Enter num: ");
scanf("%d",&num);
fprintf(fptr,"%d",num);
fclose(fptr);
|
|
|
|
|
|
|
Re: Writing data into a txt file, C [message #1835823 is a reply to message #1835812] |
Mon, 14 December 2020 07:06  |
Eclipse User |
|
|
|
Iam realy grateful for all the replies and In fact I am a first time poster here and a newbie in AVR world therefore I am here asking you questions.
@David Vavra
David Vavra wrote on Sun, 13 December 2020 07:00Quote: I am trying to save data into txt file in eclipse.
However upon calling `fopen` function I get such error while building: undefined reference to `fopen'
Actually, you are trying to save data to a text file in a program you wrote using Eclipse.
Where is that program supposed to run?
Is fopen supported there?
Since I posted that it been couple days and now Iam aware that fopen function is not supported.
All I wanted to do is to preview how data would save into SD card.
I used my experience from other IDE's and didnt give to much thought what I am Really trying to do here, now Iam aware how bizzare my Idea was.
I decided to go streight to saving data on SD card with help of FatFs libraries.
@Joost KraaijeveldFriend
Quote:Based on your usage of USART_TX_String you are writing a program for some Atmel environment (Arduino?).
As stated on https://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html: "Also, since there is no notion of "file" whatsoever to avr-libc, there is no function fopen() that could be used to associate a stream to some device. "
Yes, yes it is Atmels environment but its no Arduino, its standalone Atmega32 connected by SPI to PC with help of a USB programator.
And as I typed above, I made myself more familiar with manual for avr library and decided to forfeit that idea and get straight to it.
|
|
|
Powered by
FUDForum. Page generated in 0.08105 seconds