I need something to do!

This is a discussion on I need something to do! within the C++ Programming forums, part of the General Programming Boards category; Ok, I'm new here, I'm not new to C++ however, I have been out of practice for about a year. ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    23

    I need something to do!

    Ok, I'm new here, I'm not new to C++ however, I have been out of practice for about a year. I was the best in my class and want to get my edge back for fall quarter....if somebody could give me a couple of programs to work on or possibly a website with programs and then sources to look at after I'm done to compair my code to...thanks...just trying to get back into it...

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Why don't you write a program to output the bit patterns of different types of values. Example: shorts, integers, floats, doubles, characters. Good little exercise. Oh yeah, throw in support for Big and Little Endian support.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    23
    Ok, I feel embarassed asking but, explain please. How about an example of a bit pattern....I don't recall what that is...man if we went over this and I don't remember I really am out of practice.

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    23
    do you mean

    user input 1 consol output 0001
    user input 2 consol output 0010

    (EDIT)
    That would be a binary pattern....sorry
    Last edited by fastmonkey; 08-16-2002 at 11:53 PM.
    This space for Rent.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by fastmonkey
    Ok, I feel embarassed asking but, explain please. How about an example of a bit pattern....I don't recall what that is...man if we went over this and I don't remember I really am out of practice.
    No need to feel embarassed. The program will involve some lower level C stuff to do. Definitely bit shifting and stuff like that. As far as bit patterns, I mean say the user wants to get the bit pattern for short. Typically a short is composed of 2 bytes. So, if the user entered 45 for his short. You program would produce:

    0000000000101101 [ Big-Endian ]
    (edit: oops, only had 1 byte orginally, needed 8 more zeros for the additional byte)

    Don't worry about little-endian for now, just get it working like that for starters. If you think this is a little to advanced for you perhaps I can give some other examples? This is just was off the top of my head. If you need some help, just let me know.

    edit: Binary pattern , bit patterns its all the same
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  6. #6
    Registered User
    Join Date
    Aug 2002
    Posts
    23
    ah...so I was on the right track...I kinda recall bit shifting...let me go dig out my old c++ book and see what I can find out...this shouldn't take that long....I think I'll start off with what you call Big Endian (?)...
    Last edited by fastmonkey; 08-16-2002 at 11:51 PM.
    This space for Rent.

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by fastmonkey
    ah...so I was on the right track...I kinda recall bit shifting...let me go dig out my old c++ book and see what I can find out...this shouldn't take that long....I think I'll start off with what you call Big Endian (?)...
    Big-Endian vs. Little-Endian

    This is how bytes are interpreted by processors. This just has to do with the order of bytes in multi-byte data types. In little-endian the low-byte is stored in the lower memory address and high-byte is in the high address location. It is reversed for big-endian.

    Here are some quick notes:

    *Endian is the order in which bytes of a word are stored in memory
    *A 32-bit integer is composed of 4 8-bit bytes.

    If an integer, say 0x12345678 was stored at address 1000, how would the four bytes be ordered?

    Code:
    Address:       1000          1001          1002       1003
    big-endian      12            34            56         78
    little-endian   78            56            34         12
    Some processors and their endianess:


    Processor Family and Endian
    ---------------------------------
    Pentium (Intel) = Little
    Alpha (DEC/Compaq) = Little
    680x0 (Motorola) = Big
    PowerPC (Motorola & IBM) = Big
    SPARC (Sun) = Big
    MIPS (SGI) = Big


    Internet is big-endian!!
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  8. #8
    Unregistered
    Guest
    Ok, I'm still stumped on the Endian thing...maybe it's a little advanced for me just yet...is their a tutorial or other in-depth information in regards to it? Just because I don't understand it now doesn't mean I can live with it...I want to know whatever I don't know...lol...

  9. #9
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    You can read about it lots of places. Here are a few I grabbed off of google that looked promising.

    http://www.bitbanksoftware.com/code5.htm
    http://www.cs.umass.edu/~verts/cs32/endian.html
    http://www.webopedia.com/TERM/b/big_endian.html

    Try those , they should clear it up for you.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  10. #10
    Registered User
    Join Date
    Aug 2002
    Posts
    23
    That makes since...thanks...I think the 2nd link explained why you need to understand the difference between little and big endian where as the 1st best described the differences and what they are...I didn't get to look at the 3rd because my DSL's been tweaking out lately and couldn't find the site....it's kinda amazing about the inconsistant nature of this...some programs require you to use little while other need you to use big...I guess it depends on the aplication which would be more efficent....just my obscure observation...
    This space for Rent.

  11. #11
    elad
    Guest
    try the puzzles Michael Jones posts at:

    http://www.m0rph.com/bbs/

  12. #12
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    There's also some stuff on the Contest Board, right here at cprog.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  13. #13
    Registered User
    Join Date
    Aug 2002
    Posts
    23
    Ok, I've finnished the first part of the program. I have about 30 minutes into this which I feel is really good considering it's been 1 year since I've done any programming...(I had to go back and remember how to use seperate sheets!)

    It accepts an correctly converts any integer from 1 to 2147483647 to it's binary equivelent.....
    Attached Files Attached Files
    This space for Rent.

  14. #14
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by fastmonkey
    Ok, I've finnished the first part of the program. I have about 30 minutes into this which I feel is really good considering it's been 1 year since I've done any programming...(I had to go back and remember how to use seperate sheets!)

    It accepts an correctly converts any integer from 1 to 2147483647 to it's binary equivelent.....
    dude, don't you think that's a few too many source files for a program that size?
    hello, internet!

  15. #15
    Registered User
    Join Date
    Aug 2002
    Posts
    23
    It will be getting much bigger, I perfer to start the program object oriented...I could have done it all in the main file, but I didn't...
    This space for Rent.

Popular pages Recent additions subscribe to a feed

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