Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. Eager to learn
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2009
    Location
    Maryland, USA
    Posts
    2,230
    Rep Power
    2179

    Questions about C


    I'm fairly new to C. I've dabbled in C++ and Java, and I have a course in C this fall so I am trying to grasp the basics

    I'm playing around with trying to display basically "hello world" and I keep getting a warning "Source code not compiled" when I run it. I feel as if it might be something with DevC++ but I saved it as a C file, not C++. Any ideas? I'm definately compiling it with success, just can't run it. I even googled a hello world example and it didn't help at all.

    Code:
    /* This is cool comment that I made */
    
    int main()
    
    {
       printf("press enter to continue...\n");
       system("pause");
        
        return 0;
    }
    Last edited by Skipt; August 4th, 2013 at 03:21 PM.
    "Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

    "so no-one has actually bothered to post an original quote ? what's wrong with making up your own?"
    - marnixR
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    109
    Rep Power
    3
    I also use Dev compiler.

    printf("Hello World");

    Or

    puts("hello world");

    Show your entire code.

    And the other code you posted also works.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    I'm definately compiling it with success, just can't run it.
    Are you sure?

    What include files are you including? There should be at least two.

    Jim
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    109
    Rep Power
    3
    Originally Posted by jimblumberg
    Are you sure?

    What include files are you including? There should be at least two.

    Jim
    I ran his code without any include fles and it still compiled. We use the same compiler.

    Maybe the window closes immediately after running the prog?

    If yes then :

    getch(); <------

    return 0;



    >Works??
  8. #5
  9. Eager to learn
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2009
    Location
    Maryland, USA
    Posts
    2,230
    Rep Power
    2179
    Ive tried getch() and system("PAUSE");

    I'm downloading Visual C++ from microsoft now and seeing if that helps. I tried downloading the regular bloodshed dev C++ version but the links were down so I downloaded the beta. Maybe it's some kind of bug, but google searches says this is nothing new. Let's see if this new editor works

    Also, that was my entire code....it's just basically a hello world program....
    "Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

    "so no-one has actually bothered to post an original quote ? what's wrong with making up your own?"
    - marnixR
  10. #6
  11. Eager to learn
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2009
    Location
    Maryland, USA
    Posts
    2,230
    Rep Power
    2179
    Originally Posted by jimblumberg
    Are you sure?

    What include files are you including? There should be at least two.

    Jim
    Why should there be at least two?
    "Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

    "so no-one has actually bothered to post an original quote ? what's wrong with making up your own?"
    - marnixR
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    109
    Rep Power
    3
    Originally Posted by Skipt
    Ive tried getch() and system("PAUSE");

    I'm downloading Visual C++ from microsoft now and seeing if that helps. I tried downloading the regular bloodshed dev C++ version but the links were down so I downloaded the beta. Maybe it's some kind of bug, but google searches says this is nothing new. Let's see if this new editor works

    Also, that was my entire code....it's just basically a hello world program....
    :confused: lol

    Well, try typing #include<stdio.h> at the top, should always work.
    Code:
    #include<stdio.h>
    
    int main()
    {
        printf("hello world");
        getch();
        return 0;
    }
  14. #8
  15. Eager to learn
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2009
    Location
    Maryland, USA
    Posts
    2,230
    Rep Power
    2179
    I've tried that. Right now I'm assuming it's a compiler error so I'm downloading Microsoft Visual C++ 2012 and gonna see how that works.
    "Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

    "so no-one has actually bothered to post an original quote ? what's wrong with making up your own?"
    - marnixR
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    You need <stdio.h> to use printf(). And you need <stdlib.h> to use the system() call.

    Here are the compiler error messages I get when I try to compile your code:

    /main.c||In function ‘main’:|
    /main.c|6|error: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]|
    /main.c|6|warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]|
    /main.c|7|error: implicit declaration of function ‘system’ [-Wimplicit-function-declaration]|
    Perhaps you need to increase your compiler warning level and insure you don't ignore any warnings or errors.


    Jim
  18. #10
  19. Eager to learn
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2009
    Location
    Maryland, USA
    Posts
    2,230
    Rep Power
    2179
    I'm still getting error of source file not compiled

    Code:
    #include <stdlib.h>
    #include <stdio.h>
    
    int main()
    {
        printf("hello");
        
        return 0;
        
    }
    Do i need to download something else? All I did was go to the website and download the beta. it's supposed to include mingw so that can't be it.
    "Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

    "so no-one has actually bothered to post an original quote ? what's wrong with making up your own?"
    - marnixR
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    What are your compile errors?

    Did you create a project?

    Perhaps you could post a screen shot of your compiler in action?

    Jim
  22. #12
  23. Eager to learn
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2009
    Location
    Maryland, USA
    Posts
    2,230
    Rep Power
    2179
    Ok after googling, it seems it was a pathing error.

    http://learntogeek.com/miscellaneous/solved-source-file-not-compiled-error-in-dev-cpp/

    I did what he said, and now it won't let me compile. It says ‘Aborted(program collect2)’

    Since the people on DevC++ didn't keep up to date with this program, you think it is just because I'm using Windows 8? If so, what alternative program should I use to code in?
    "Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

    "so no-one has actually bothered to post an original quote ? what's wrong with making up your own?"
    - marnixR
  24. #13
  25. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,169
    Rep Power
    2222
    Originally Posted by Skipt
    Why should there be at least two?
    You are using two library functions which are prototyped in two different header files: printf in stdio.h and system in stdlib.h (I think, or maybe in dos.h; Read The Manual (RTFM!) for system(), which will tell you which header file you need to #include).

    Actually, that's exactly the same as in C++, with which you claim to already have some experience. For that matter, if you know C++, then you already know C, since C++ is largely a super-set of C. Though most C++ books won't tell you about C-style strings nor about any kind of I/O except for iostreams.


    As for your original problem, it looks like something went wrong with the installation of Dev-C++.
  26. #14
  27. Eager to learn
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2009
    Location
    Maryland, USA
    Posts
    2,230
    Rep Power
    2179
    Oh yea, I knew that, I thought he meant actual files that I wrote myself. Off the top of my head, I thought those were called libraries, oh well.

    And yeah, it has been quite a few years since I've done much with it. I've already noticed its very similar. Right now I'm trying to figure out a workaround by installing it in windows 7 compatibility mode. I'll keep you all updated

    edit: just read this on the site

    "System : Windows 95/98/NT/2000/XP"

    -_-
    Last edited by Skipt; August 4th, 2013 at 05:45 PM.
    "Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

    "so no-one has actually bothered to post an original quote ? what's wrong with making up your own?"
    - marnixR
  28. #15
  29. Eager to learn
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2009
    Location
    Maryland, USA
    Posts
    2,230
    Rep Power
    2179
    ...okay running in XP compatibility didn't work. I'm out of ideas
    "Quality of responses may vary. I reserve the right to change my mind for any reason what-so-ever without admitting I was wrong. I'd prefer to change your mind however, it's easier on my ego". - jwdonahue

    "so no-one has actually bothered to post an original quote ? what's wrong with making up your own?"
    - marnixR
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo