bitshift

Discussion in 'C Programming' started by Bill Cunningham, Nov 8, 2011.

  1. I wrote some code that is now gone or I'd post it. This code took a jpeg
    file of around 45Mb and I used the tilde operator to turn it "inside out". I
    believe I was successful and when I tried to "reshift" the bits it didn't
    work too well. Here's s snippet of what I can remember.

    int a,b;
    a=~b;

    while ((a=fgetc(fr))!=EOF)
    fputc(a,fw);

    This might not be exact but once the shift was made and the file was
    rendered incompatible it couldn't be restored.

    Bill
    Bill Cunningham, Nov 8, 2011
    #1
    1. Advertising

  2. Bill Cunningham

    Lew Pitcher Guest

    On November 8, 2011 18:05, in comp.lang.c, d wrote:

    > I wrote some code that is now gone or I'd post it. This code took a
    > jpeg
    > file of around 45Mb and I used the tilde operator to turn it "inside out".
    > I believe I was successful and when I tried to "reshift" the bits it
    > didn't work too well. Here's s snippet of what I can remember.
    >
    > int a,b;
    > a=~b;
    >
    > while ((a=fgetc(fr))!=EOF)
    > fputc(a,fw);
    >


    Not quite. Your original code was "to take an ELF format file and turn it
    inside out". And the code was somewhat more involved than the sample you
    posted above.

    > This might not be exact but once the shift was made and the file was
    > rendered incompatible it couldn't be restored.
    >
    > Bill
    >
    >


    Yes, Bill, and we discussed the problem when you posted your code.

    You can find your original posting at
    http://groups.google.com/group/comp.lang.c/msg/add65513a89893b8
    and the entire thread (including the analysis of your code issues) at
    http://groups.google.com/group/comp.lang.c/browse_thread/thread/5a37bd31826939b3/522175a9c67ec50b

    --
    Lew Pitcher
    Master Codewright & JOAT-in-training | Registered Linux User #112576
    Me: http://pitcher.digitalfreehold.ca/ | Just Linux: http://justlinux.ca/
    ---------- Slackware - Because I know what I'm doing. ------
    Lew Pitcher, Nov 9, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan
    Replies:
    4
    Views:
    2,968
    Rusty Wright
    Feb 14, 2005
  2. bollod
    Replies:
    12
    Views:
    507
    Richard Heathfield
    Dec 27, 2003
  3. Replies:
    8
    Views:
    329
    Larry I Smith
    Feb 10, 2006
  4. Replies:
    6
    Views:
    371
    Grant Edwards
    May 24, 2007
  5. Serve Laurijssen

    bitshift operator problem

    Serve Laurijssen, Sep 5, 2008, in forum: C Programming
    Replies:
    13
    Views:
    610
    Ben Bacarisse
    Sep 6, 2008
Loading...

Share This Page