Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » 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 #1869402] Thu, 15 August 2024 20:34
Ria Prakash is currently offline Ria PrakashFriend
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

Previous Topic:Compile HelloWorld took too long time
Next Topic:OpenFOAM #includes inside functions
Goto Forum:
  


Current Time: Fri Oct 04 03:28:33 GMT 2024

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

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

Back to the top