Read a file in windows using linux

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frank511
    New Member
    • Feb 2017
    • 1

    Read a file in windows using linux

    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?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    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.

    Comment

    Working...