How to read in/write to a file in Eclipse C [message #1869402] |
Thu, 15 August 2024 20:34 |
Ria Prakash Messages: 3 Registered: August 2024 |
Junior Member |
|
|
I'm trying to read in data from a txt file into my main file and also to write some function output to a new file but have not had success in doing either.
Currently have these lines, where both pointers are always null, and I don't know why. I tried moving the c_readin file to the eclipse_workspace folder for this project itself, and the pointer was still null.
int main(void)
{
FILE *fptr1 = fopen("c_readin.txt", "r");
if(fptr1 == NULL)
{
printf("Noooooo!");
exit(1);
}
FILE *fptr = fopen("C:/Users/riaprakash/Desktop/ml_output.txt", "w");
if(fptr == NULL)
{
printf("Error!");
exit(1);
}
memcpy(printed_out, ml_data32, sizeof(printed_out));
fprintf(fptr, "%x\n", printed_out[0]);
fclose(fptr);
return 0;
}
[Updated on: Thu, 15 August 2024 20:36] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03164 seconds