Thread: Problem with rand function

  1. #1
    Registered User
    Join Date
    May 2016
    Posts
    2

    Problem with rand function

    [SOLVED]

    Hi,


    I cannot figure out what is wrong with this picture


    Code:
    Alphabet = "ABCDEFG";
    
    
    for (int i = 0; i < 3; i++)
      cout << Alphabet[rand() % Alphabet.length()] << endl;

    I get


    Code:
    g++ -DPACKAGE_NAME=\"InCoM\" -DPACKAGE_TARNAME=\"incom\" -DPACKAGE_VERSION=\"0.01\" -DPACKAGE_STRING=\"InCoM\ 0.01\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"incom\" -DVERSION=\"0.01\" -DHAVE_BOOST=/\*\*/ -DHAVE_BOOST_SYSTEM=/\*\*/ -DHAVE_BOOST_FILESYSTEM=/\*\*/ -DHAVE_BOOST_PROGRAM_OPTIONS=/\*\*/ -I.  -I../../src/include -I/usr/include  -std=c++0x -O3 -MT InCoM-InCoM.o -MD -MP -MF .deps/InCoM-InCoM.Tpo -c -o InCoM-InCoM.o `test -f 'InCoM.cpp' || echo './'`InCoM.cpp
    In file included from InCoM.cpp:35:0:
    ../../src/include/Utility/StrToOcc.hpp: In instantiation of ‘std::string sto::StrToVec<Tint>::GetRandom(Tint) [with Tint = int; std::string = std::basic_string<char>]’:
    ../../src/include/Utility/StrToOcc.hpp:220:54:   required from ‘void sto::StrToVec<Tint>::MakeOccVector(const string&) [with Tint = int; std::string = std::basic_string<char>]’
    InCoM.cpp:156:37:   required from here
    ../../src/include/Utility/StrToOcc.hpp:331:7: error: no match for call to ‘(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) ()’
      cout << Alphabet[rand() % Alphabet.length()] << endl;
                             ^
    
    make[1]: *** [InCoM-InCoM.o] Error 1

    It was working a minute ago and now...



    and then I accidentally erased std namespace ....


    SORRY FOR WASTING TIME
    Last edited by mxs; 05-26-2016 at 04:40 PM. Reason: SOLVED

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to use the rand function?
    By Mohit Saxena in forum C Programming
    Replies: 10
    Last Post: 09-24-2014, 12:47 PM
  2. Replies: 2
    Last Post: 11-14-2011, 08:08 AM
  3. Rand() function...
    By Ash1981 in forum C Programming
    Replies: 7
    Last Post: 01-26-2006, 09:04 AM
  4. Rand() function
    By Da-Nuka in forum C++ Programming
    Replies: 10
    Last Post: 12-26-2004, 08:12 AM
  5. I need help using the rand() function
    By incognito in forum C++ Programming
    Replies: 14
    Last Post: 06-02-2002, 02:48 PM

Tags for this Thread