my doubts in C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • geese786@gmail.com

    #1

    my doubts in C

    int fp

    fp = fopen ( "r , "abc.txt);;

    it is giving error "file not opening"
  • Chris Dollin

    #2
    Re: my doubts in C

    geese786@gmail. com wrote:
    int fp
    >
    fp = fopen ( "r , "abc.txt);;
    >
    it is giving error "file not opening"
    I find this highly surprising, since the code isn't remotely
    compilable.

    If one hallucinates that fp is a FILE*, and that the code
    appears within, say, main, and that the fopen call repairs
    to

    fp = fopen( "r", "abc.txt" );

    to get that problem report, then I'd expect it to be because
    there's no file called `r` to open.

    --
    "Its flagships were suns, its smallest vessels, /The City and the Stars/
    planets."

    Hewlett-Packard Limited registered office: Cain Road, Bracknell,
    registered no: 690597 England Berks RG12 1HN

    Comment

    • John Bode

      #3
      Re: my doubts in C

      On Apr 2, 7:49 am, geese...@gmail. com wrote:
      int fp
      >
      fp = fopen ( "r , "abc.txt);;
      >
      it is giving error "file not opening"
      Ignoring the obvious syntax errors, the problem is that you have your
      parameters reversed. It *should* be

      fp = fopen("abc.txt" , "r");

      What reference manual are you using?

      Comment

      • CBFalconer

        #4
        Re: my doubts in C

        geese786@gmail. com wrote:
        >
        int fp
        >
        fp = fopen ( "r , "abc.txt);;
        >
        it is giving error "file not opening"
        Sounds like a reasonable response to that code.

        --
        [mail]: Chuck F (cbfalconer at maineline dot net)
        [page]: <http://cbfalconer.home .att.net>
        Try the download section.



        --
        Posted via a free Usenet account from http://www.teranews.com

        Comment

        • Kenneth Brody

          #5
          Re: my doubts in C

          Chris Dollin wrote:
          >
          geese786@gmail. com wrote:
          >
          int fp

          fp = fopen ( "r , "abc.txt);;

          it is giving error "file not opening"
          >
          I find this highly surprising, since the code isn't remotely
          compilable.
          >
          If one hallucinates that fp is a FILE*, and that the code
          appears within, say, main, and that the fopen call repairs
          to
          >
          fp = fopen( "r", "abc.txt" );
          >
          to get that problem report, then I'd expect it to be because
          there's no file called `r` to open.
          [Ignoring the trolling of the OP...]

          7.19.5.3p3 states:

          If the string is one of the following, the file is open in the
          indicated mode. Otherwise, the behavior is undefined.

          It is perfectly acceptable that the UB outputs "file not opening"
          as a result of this, once the obvious syntax errors are "fixed",
          whether or not a file named "r" exists. :-)

          --
          +-------------------------+--------------------+-----------------------+
          | Kenneth J. Brody | www.hvcomputer.com | #include |
          | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
          +-------------------------+--------------------+-----------------------+
          Don't e-mail me at: <mailto:ThisIsA SpamTrap@gmail. com>


          Comment

          Working...