Thread: buffer

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    291

    buffer

    Hey.

    Im trying to make a circular buffer in c but I dont know how to go about doing it. Was wondering if anyone could help me out with simple code example or point to any related web site. Have search both this site and google without finding any good help.

    Appreciate any response.

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    291
    Why use :
    #define N 10

    could I use :
    const n = 10;

    If I need multiple buffers can I place above code inside struct ? (Is struct similar to class ? )

    btw, thanks for your response

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    351
    a struct is similar to a class in as much as it encapsulates the attributes of an object.

    Code:
    struct car
    {
            char *reg;
            int number_of_wheels;
            int engine_capacity;
    }
    normally behaviour, i.e. functions, is defined outside of the struct as seperate entities.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    In C++, structs and classes are identical save for one trait: by default, all class members are private whereas with structs, public. Thus even structs can have methods(functions). This is why C++ is superior to C.
    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;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  2. writing a pack-style function, any advices?
    By isaac_s in forum C Programming
    Replies: 10
    Last Post: 07-08-2006, 08:09 PM
  3. buffer contents swapping
    By daluu in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2004, 02:34 PM
  4. Tetris Questions
    By KneeGrow in forum Game Programming
    Replies: 19
    Last Post: 10-28-2003, 11:12 PM
  5. Console Screen Buffer
    By GaPe in forum Windows Programming
    Replies: 0
    Last Post: 02-06-2003, 05:15 AM