954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Eclipse C++ in Fedora on USB stick

I'm having problems reading or writing files in my C++ program.
I'm using Fedora 16 on a USB stick and Eclipse for C/C++ developers.

Here's snippet of code from my program. fp is always 0.
I've also got other code that is loading files (which always fail).

I've tried running Eclipse using 'sudo' but that doesn't help.
I don't receive any error messages.

FILE* fp = fopen("test.xyz", "r");
if(fp)
{
    fprintf(fp, "test123");
    fclose(fp);
}


Any help would be great. Thanks!

Chris

chrisjubb
Newbie Poster
5 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

Sorry that should be "w" as the type parameter on the fopen call.

chrisjubb
Newbie Poster
5 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

I assume you installed the CDT plugin for Eclipse? What is your OS, and what compiler are you using? Have you verified that your project is using the correct compiler, etc? Eclipse is picking about that sort of stuff.

rubberman
Posting Virtuoso
1,564 posts since Mar 2010
Reputation Points: 277
Solved Threads: 179
 

Also, for me, on Linux/Unix systems at least, I MUCH prefer a simple Makefile and the standard C compiler options. If you are using Visual Stupido on Windoze, then you should really use the VS environment.

rubberman
Posting Virtuoso
1,564 posts since Mar 2010
Reputation Points: 277
Solved Threads: 179
 

I'm using Fedora and setup a new project. Everything else was fine in the project.
The thing I figured out I was doing wrong was specifying the wrong type of slashes in the filenames.

I was doing:[INDENT]folder\\filename.png[/INDENT]which works on Windows but not Linux.

But I should have been doing:[INDENT]folder/filename.png[/INDENT]Which works on Linux.

Time for some abstraction of my file loading...

Thanks anyway.

chrisjubb
Newbie Poster
5 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: