Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to read in/write to a file in Eclipse C(read in/write to a file in Eclipse C not working)
How to read in/write to a file in Eclipse C [message #1869405] Thu, 15 August 2024 20:39 Go to next message
Eclipse UserFriend
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;
}
Re: How to read in/write to a file in Eclipse C [message #1873076 is a reply to message #1869405] Thu, 05 December 2024 12:45 Go to previous message
Eclipse UserFriend
Your file paths are likely the issue. Use absolute paths for both files to ensure they're correctly located, and check that you have the necessary read/write permissions. Also, replace printf("Error!") with perror to get detailed error messages for easier debugging!
Previous Topic:dark theme highlightin unreadable problem
Next Topic:How to configure remote Oracle WebLogic Server on Eclipse for Windows
Goto Forum:
  


Current Time: Fri Feb 14 03:07:21 GMT 2025

Powered by FUDForum. Page generated in 0.07774 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top