Thread: reading bitmap into array

  1. #31
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Sebastiani View Post
    puts("Iceberg at 12 o'clock - full speed ahead!");
    No you are supposed to do that first, then scuttle the vessel.

    puts("The Captain has won the game. Swim for your lives.");
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #32
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    puts("I don't know how to swim!");

    please throw a life preserver, I don't care if we need to unwind the stack!
    Last edited by ಠ_ಠ; 07-26-2009 at 03:19 PM.
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

  3. #33
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You need to compile with -SNAFU -allfloats
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #34
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Thanks for all the suggestions but despite my constant resizing being inefficient, it's part of the directions, so I will follow that.

    In that case, go back to your original code.

    Code:
    set 'nsize' to 1 and allocate a byte. 
    	loop (omit the loop control field in the for loop entirely)
    	fread one byte
    	if fread fails, exit the loop
    	increment bitmap::size
    	if bitmap::size is equal to 'nsize', double 'nsize' and realloc (as you had in the original code)
    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;
    }

  5. #35
    Registered User
    Join Date
    Jul 2009
    Posts
    14
    Haha, you guys seem to be having fun.

    Thanks a lot for all the help! I've successfully been able to read from the header all the necessary information and so I'm just working on a nifty encryption now. Thanks again!

  6. #36
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> You need to compile with -SNAFU -allfloats

    That won't work with GCC, though. How about -mhard-float -mno-fast-fix -mno-single-exit?

    Yeah, that sounds about right.
    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: 7
    Last Post: 02-02-2009, 07:27 AM
  2. Reading a list of ints from file into an array
    By mesmer in forum C Programming
    Replies: 1
    Last Post: 11-10-2008, 06:45 AM
  3. Reading integers from a File into an Array
    By bobby19 in forum C Programming
    Replies: 13
    Last Post: 10-09-2006, 01:36 AM
  4. Reading a file into an array for fast access later
    By matsharp in forum C Programming
    Replies: 10
    Last Post: 08-03-2006, 02:42 AM
  5. Replies: 1
    Last Post: 04-25-2006, 12:14 AM