Question regarding strcpy...

This is a discussion on Question regarding strcpy... within the C Programming forums, part of the General Programming Boards category; Is there an equivalent to the strcpy function, for floating point numbers, and integer values? Thanks....

  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,796
    >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, 11:34 AM
  3. strcpy question
    By cman9999 in forum C Programming
    Replies: 9
    Last Post: 03-07-2003, 01:03 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM
  5. strcpy
    By Luigi in forum C++ Programming
    Replies: 17
    Last Post: 02-16-2003, 03:11 PM

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