Like Tree2Likes

include c++ in c

This is a discussion on include c++ in c within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by ZuK Yes. The c compiler propably never even got that far to see that call. Now your ...

  1. #16
    quo
    quo is offline
    Registered User
    Join Date
    May 2011
    Posts
    116
    Quote Originally Posted by ZuK View Post
    Yes. The c compiler propably never even got that far to see that call.

    Now your problem seems to be that MS standard library doesn't have any drand48().
    I changed it to cstdlib.
    How can I fix this problem?

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    62
    Quote Originally Posted by quo View Post
    I changed it to cstdlib.
    How can I fix this problem?
    Quick and dirty:

    Code:
    double drand48() // random number between [0.0, 1.0]
    {
      return rand() / (double)RAND_MAX;
    }
    
    ...
    
    srand(time(0)); // somewhere in main()
    However, if the random numbers will be as random (uniformly distributed) as the results you would get from the original drand48() function, I don't know.
    stahta01 and quo like this.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Does #include indirectly include the source file too?
    By Lord Asriel in forum C Programming
    Replies: 10
    Last Post: 11-30-2011, 07:20 AM
  2. Replies: 1
    Last Post: 11-06-2011, 05:20 PM
  3. basic difference between #include<> and #include""
    By gunjansethi in forum C Programming
    Replies: 1
    Last Post: 03-26-2010, 12:53 AM
  4. #include <windows.h> and #include <wininet.h>
    By steve1_rm in forum C++ Programming
    Replies: 4
    Last Post: 03-30-2009, 11:14 AM
  5. Which came first? #include <stdio.h> or #include <stdlib.h> ?
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-14-2002, 09:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21