Thread: RANDMAX problem!

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    81

    Smile RANDMAX problem!

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void){
    	int r;
    		r = rand();
    		printf("1] number: %d", r);
    		r = (r/RANDMAX);
    		printf("2] number: %d", r);
    
    	return 0;
    }
    output:
    Code:
    ex2.c: In function ‘main’:
    ex2.c:9: error: ‘RANDMAX’ undeclared (first use in this function)
    ex2.c:9: error: (Each undeclared identifier is reported only once
    ex2.c:9: error: for each function it appears in.
    i don 't get it. Sometimes this specific error appears and other is does not...
    what' s the problem guys???

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    RAND_MAX, not RANDMAX
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    81
    Stupid mistake...thanks!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM