Problem in compiling in linux

This is a discussion on Problem in compiling in linux within the C Programming forums, part of the General Programming Boards category; ptr=strrchr(path,'\'); strncpy(path1,path,ptr-path); path1[ptr-path]='

Thread: Problem in compiling in linux

'; strcat(path1,"\file.txt"); output_file=fopen(path1,"w"); here path is some path of an input file. this code works fine for me ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    8

    Problem in compiling in linux

    ptr=strrchr(path,'\\');

    strncpy(path1,path,ptr-path);

    path1[ptr-path]='\0';

    strcat(path1,"\\file.txt");

    output_file=fopen(path1,"w");
    here path is some path of an input file. this code works fine for me in borlandc. when i use gcc it shows "Segmentation fault (core dumped)" error.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    My guess is that you don't find the correct file because you are using \\ instead of / in your file-path. Backslash is how MS splits paths, whilst Unix/Linux uses forward slashes.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  2. SSHDOS linux modification GET problem
    By berg in forum C Programming
    Replies: 3
    Last Post: 04-11-2007, 07:13 AM
  3. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 02:09 AM
  4. compiling win32 apps under linux?
    By talz13 in forum Linux Programming
    Replies: 11
    Last Post: 02-07-2005, 12:43 PM
  5. Linux vs PC Problem
    By shane1985 in forum C++ Programming
    Replies: 1
    Last Post: 11-06-2003, 09:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21