Thread: Question regarding strcpy...

  1. #1
    Unregistered
    Guest

    Question regarding strcpy...

    Is there an equivalent to the strcpy function, for floating point numbers, and integer values?

    Thanks.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    For floats and ints you just assign the values from one variable to another directly.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    sprintf(buff, "This works %.2f%% of the time...\n", 100);
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Nick
    Guest
    You have memcpy that copies a group of bytes but you
    have to be careful with this one. Often times
    you might find yourself writing code like this

    int a[100]
    int b[100];

    memcpy(a, b, 100); But what you really wanted was
    memcpy(a, b, 100 * sizeof (int)).

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    One question, three different answers. Maybe unreg better rephrase the question in order to clarify what they want to know. Or better still, show a snippet of code they are having trouble with.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >One question, three different answers.
    It sounds like Nick's answer was the most correct for the question.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Strcpy
    By Godders_2k in forum C Programming
    Replies: 17
    Last Post: 12-12-2007, 12:34 PM
  3. strcpy question
    By cman9999 in forum C Programming
    Replies: 9
    Last Post: 03-07-2003, 02:03 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. strcpy
    By Luigi in forum C++ Programming
    Replies: 17
    Last Post: 02-16-2003, 04:11 PM