By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Read a file in windows using linux

P: 1
I have a small risc processor system using linux. I want to read/write to a file on a windows machine that is connected using a cross-over rj45 cable. I have tried many permutations but with no success.
My c code looks like the following:

fp = fopen("/temp/data.txt", "w+");

I have also tried:

fp = fopen("/169.254.5.155/temp/data.txt", "w+");

with lots of variations of the " / "
The IP is that of the PC I want to talk to.
The temp folder is at c:\temp on the windows machine and is set to share.
When I run my c code on the linux machine, I get Segmentation fault

What am I doing wrong?
Feb 20 '17 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
Are you using a full path to the file?

Be sure to test fp after the fopen call. A NULL pointer means the file didn't open. Using fp of 0 gets you a segmentation fault.
Feb 21 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.