Thread: need help fındıng error

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    18

    need help fındıng error

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    FILE * p;
    int main()
    {
    
    
        p=fopen("meryem.txt","a+");
        if(fopen("meryem.txt","a+"))
        {
        printf("dosya acıldı:");
        }
        else
        printf("dosya acılamadı:");
        fclose(p);
    
    
    
    
    }
    it always says p undefined, even though it works on my friends computer.

  2. #2
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    p *is* defined, so either your headers are missing or broken (i.e compiler /IDE configuration issues). My compiler doesn't complain about that code at all (though it does complain about you not returning anything from main - stick a return(EXIT_SUCCESS) in at the end of that function).

    P.S. Your text is in UTF-8, so I assume you have a UTF-8 compatible compiler?

    P.P.S. Learn to indent properly.

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    18
    i dont have a problem with anything else, i use codeblocks and even though it works on my friends computer it doesnt always work on mine. i dont think the headers are missing or broken..

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    396
    You should copy/paste your compiler error.

  5. #5
    Registered User
    Join Date
    Dec 2011
    Posts
    36
    there is some problem with your codeblocks settings not the code

  6. #6
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    Quote Originally Posted by zeybek258388 View Post
    i dont have a problem with anything else, i use codeblocks and even though it works on my friends computer it doesnt always work on mine. i dont think the headers are missing or broken..
    Put it this way - a million people would have jumped on your code by now if there was a problem with it (and even I mentioned two completely unrelated things about it). The code is fine. If a FILE isn't defined properly, that's because you didn't #include stdio.h (which you have) or because the compiler can't *find* stdio.h. FILE is pretty much an in-built feature of the C standard library and not likely to be missing from your compiler entirely. You're not looking at something that's staring you in the face - your development environment is bugged. Either you're not heeding warnings/errors that it's throwing at you, or it's not doing what you think it's doing.

    That code compiles perfectly. FILE is well-defined in all C environments so long as you #include stdio.h (which you have). The problem's not the code.

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by zeybek258388 View Post
    i dont have a problem with anything else, i use codeblocks and even though it works on my friends computer it doesnt always work on mine. i dont think the headers are missing or broken..
    FAQ-Compiling (errors) - CodeBlocks

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 11-28-2011, 11:48 AM
  2. Replies: 4
    Last Post: 07-24-2011, 09:38 PM
  3. Replies: 1
    Last Post: 11-15-2010, 11:14 AM
  4. Replies: 3
    Last Post: 10-02-2007, 09:12 PM
  5. Replies: 1
    Last Post: 01-11-2007, 05:22 PM