Thread: C Compiler for a C beginnger

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    2

    C Compiler for a C beginnger

    I'm going crazy over this
    So I downloaded like 5 C compilers for Win XP and all of them give me the same problem : when I compiler & run a command prompt window appears like if it was there for me to actually give the program the input it needs...

    ...but then it quickly dissappears and nothing else happens.


    I'm currently using Dev c++ and the same things is happening...I can't run my programs


    I'm kind of a newbie so bare with me please

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    Quote Originally Posted by Dungah
    I'm going crazy over this
    So I downloaded like 5 C compilers for Win XP and all of them give me the same problem : when I compiler & run a command prompt window appears like if it was there for me to actually give the program the input it needs...

    ...but then it quickly dissappears and nothing else happens.


    I'm currently using Dev c++ and the same things is happening...I can't run my programs


    I'm kind of a newbie so bare with me please
    Man try to execute the exe file by double clicking it or do a dirty trick and place a getchar(); at the end of the source. I think there is something about it on the faq but I really could'nt find it.
    Just as example:
    Code:
    #include <stdfoo.h>
    
    int main (void){
       foo(void);
    
       getchar();
       return 0;
    }

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    Get visual c++ express edition from the ms website free
    silk.odyssey

  5. #5
    Registered User 00Sven's Avatar
    Join Date
    Feb 2006
    Posts
    127
    I just use Dev-C++ and its built in compiler. I also set up my command prompt to be able to use the gcc command to compile so that if I need to edit quickly I can use the edit and gcc if I need to make a quick change.
    ~Sven

  6. #6
    Registered User im fine u?'s Avatar
    Join Date
    Feb 2006
    Posts
    1
    I insert my command prompt into the Dev C++ folder where my programs are, and type the name of the program at the prompt, and it runs without shutting off

    -im fine u?

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Did you have a question?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Registered User
    Join Date
    Feb 2006
    Posts
    2
    Okay my problem is partially solved but I had another question and I dind't want to make a new topic :

    So I'm making a program which probably is something very normal for beginners to be assigned to.It's that "Guess a number" program.I have almost everything checked....

    The only thing I'm bot getting right is the random number the computer should generate.It always generates the same number!So I know there is no such thing as a real random computer generated number but I don't restart my PC between each try and I still get the same number.

    Wow can I make it generate different "random" numbers?
    Better yet how can I make him generate numbers with different sizes (I can't get it to generate numbers with different number digits each time)


    Thanks in advance

  9. #9
    Registered User 00Sven's Avatar
    Join Date
    Feb 2006
    Posts
    127
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    int main(){
    int r;
    r=srand((unsigned)time(null));
    /*This creates an integer assigned to r that is random when assigned but then stays the same after it is declared.  */
    printf("%d",r);
    }
    If you want to make it within a certain range you need to use the % operator. For example if you want a random number between 1 and 100 you would do:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    int main(){
    int r;
    r=srand((unsigned)time(null))%100;
    printf("%d",r);
    return(0);
    }
    ~Sven

  10. #10
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    r=srand((unsigned)time(null));
    NULL is uppercase, not lowercase.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    int main(){
    int r;
    r=srand((unsigned)time(null))%100;
    printf("%d",r);
    return(0);
    }
    That doesn't do what you think it does. Try this program instead:
    Code:
    #include <stdio.h>  /* for printf() */
    #include <stdlib.h>  /* for rand(), srand() */
    #include <time.h>  /* for time() */
    
    int main(void) {
        int x;
        srand((unsigned)time(0));
    
        x = rand() % 100;
    
        printf("You have a %i%% change of doing that.\n", x);
    
        return 0;
    }
    See the FAQ, too, for more information.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  11. #11
    Registered User 00Sven's Avatar
    Join Date
    Feb 2006
    Posts
    127
    Yeah I noticed that. In another thread I mentioned how I was making a function for doing this easier. I messed up in that and then changed it a little to put here and didn't catch that.
    ~Sven

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  2. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  3. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  4. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  5. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM