copy_n in GNU C++ Library

This is a discussion on copy_n in GNU C++ Library within the C++ Programming forums, part of the General Programming Boards category; Hi, I am using copy_n from GNU C++ Library under Ubuntu 8.10. My code is like this: Code: #include <ext/algorithm> ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    159

    copy_n in GNU C++ Library

    Hi,
    I am using copy_n from GNU C++ Library under Ubuntu 8.10. My code is like this:
    Code:
    #include <ext/algorithm>
    using namespace std;
    void myfun(char * flags ) {
        char * flags_new = new char[3];
        copy_n(flags, 3, flags_new);
        delete [] flags_new;
      }
    
    int main()
    {
        char flags[3]={'a','b','c'};
        myfun(flags );
        return 0;
    }
    I got error : "‘copy_n’ was not declared in this scope".

    I was wondring what is the problem and how to fix it? Thanks!
    Last edited by lehe; 03-19-2009 at 09:05 PM.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    Looks non-standard to me. At any rate, you can just use:

    Code:
    std::copy(flags, flags + 3, flags_new);
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    159
    For copy, what to include?
    How do you find the header given a function in GNU standard C++ library?

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    There are C++ standard library references all over the net. Remember: It's a good idea to *always* aquire good documentation for any API you're working with. It should provide you with details such as any header files required, usage, pre-/post-conditions, constraints, etc...
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GNU Scientific Library
    By aeldes1 in forum C Programming
    Replies: 4
    Last Post: 04-10-2008, 02:47 PM
  2. Installing GNU C Library
    By prthealien in forum Linux Programming
    Replies: 2
    Last Post: 08-26-2006, 10:19 AM
  3. GNU Library Question
    By Jaken Veina in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2005, 01:57 PM
  4. Adding GNU scientific library to Dev C++
    By Jreifler in forum C++ Programming
    Replies: 1
    Last Post: 03-05-2004, 01:20 PM
  5. Gnu C++ Library Header file question?
    By xddxogm3 in forum C++ Programming
    Replies: 13
    Last Post: 10-01-2003, 03:48 PM

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