Please Please help

This is a discussion on Please Please help within the Windows Programming forums, part of the Platform Specific Boards category; I am currently working to teach myself C and move on to other languages from there. I have been working ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    3

    Angry Please Please help

    I am currently working to teach myself C and move on to other languages from there. I have been working for about two weeks on coding, etc and I have hit a wall at arrays and pointers. Please help if you can. Here is a list of questions I am attempting to answer:

    For each of the following, write a single statement that performs the indicated task. Assume that long integer variables value1 and value2 have been defines and that value 1 has been initialized to 200000.
    a. Define the variable lPtr to be a pointer to an object of type long.
    b. Assign the address of variable value1 to pointer variable lPtr.
    c. Print the value of the object pointed to by lPtr.
    d. Assign the value of the object pointed to by lPtr to variable value2.
    e. Print the value of value2.
    f. Print the address of value1.
    g. Print the address stored in lptr. Is the value printed the same as the address of value1?
    Write a printf of scanf statement for each of the following:
    a. Print unsigned integer 40000 left justified in a 15-digit field with 8 digits.
    b. Read a hexadecimal value into variable hex.
    c. Print 200 with and without a sign.
    d. Print 100 in hexadecimal form preceded by 0x.
    e. Read characters into array s until the letter p is encountered.


    Thanks,
    ThatGuy

  2. #2
    Registered User
    Join Date
    Jul 2010
    Location
    Oklahoma
    Posts
    107
    ThatGuy,

    Golly, teaching yourself C, that is monumental. I barely knew C when I was in high school, but I could whip QBasic around rather well in DOS 6.0.... I urge you to check the forum guidelines (C Board - Announcements in Forum : Windows Programming), if you're having a hard time getting replies. How do you suppose these questions are "Windows Programming" topics...? Check these suggestions out:

    Quote Originally Posted by thatguy View Post
    a. Define the variable lPtr to be a pointer to an object of type long.
    Use the 'typedef' operator...

    Quote Originally Posted by thatguy View Post
    b. Assign the address of variable value1 to pointer variable lPtr.
    Use the '&' (address-of) operator...

    Quote Originally Posted by thatguy View Post
    c. Print the value of the object pointed to by lPtr.
    Use the '*' (de-reference) operator...

    Quote Originally Posted by thatguy View Post
    d. Assign the value of the object pointed to by lPtr to variable value2.
    That one is the '*' (de-reference) operator again...

    Quote Originally Posted by thatguy View Post
    e. Print the value of value2.
    This one shows up before pointers...in stdio.h as part of format specifiers to (f)printf, right?

    Quote Originally Posted by thatguy View Post
    f. Print the address of value1.
    This uses a special conversion character according to the man page for (f)printf (in section 3). It's a 'p' rather than 's' for a string or 'd' for an integer...

    Quote Originally Posted by thatguy View Post
    g. Print the address stored in lptr. Is the value printed the same as the address of value1?
    Again with the format specifier to printf for a pointer...here's the man page: PRINTF.

    Now for some "try it outs"...I have code for the remainder of those questions.... I want to see your attempt first though, when you get a minute of course.

    Best Regards,

    New Ink -- Henry
    Kept the text books....
    Went interdisciplinary after college....
    Still looking for a real job since 2005....

    During the interim, I may be reached at ELance, vWorker, FreeLancer, oDesk and WyzAnt.

  3. #3
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407

  4. #4
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    Quote Originally Posted by thatguy View Post
    I am currently working to teach myself C and move on to other languages from there. I have been working for about two weeks on coding, etc and I have hit a wall at arrays and pointers. Please help if you can. Here is a list of questions I am attempting to answer:

    For each of the following, write a single statement that performs the indicated task. Assume that long integer variables value1 and value2 have been defines and that value 1 has been initialized to 200000.
    a. Define the variable lPtr to be a pointer to an object of type long.
    b. Assign the address of variable value1 to pointer variable lPtr.
    c. Print the value of the object pointed to by lPtr.
    d. Assign the value of the object pointed to by lPtr to variable value2.
    e. Print the value of value2.
    f. Print the address of value1.
    g. Print the address stored in lptr. Is the value printed the same as the address of value1?
    Write a printf of scanf statement for each of the following:
    a. Print unsigned integer 40000 left justified in a 15-digit field with 8 digits.
    b. Read a hexadecimal value into variable hex.
    c. Print 200 with and without a sign.
    d. Print 100 in hexadecimal form preceded by 0x.
    e. Read characters into array s until the letter p is encountered.


    Thanks,
    ThatGuy
    Those aren't a list of questions. They're a list of requirements.

    How To Ask Questions The Smart Way

    Homework Policy: C Board - Announcements in Forum : General Programming Boards

  5. #5
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    Cross Post??

    Not really undrstanding my school work, could use some help - Beginner C/C++ - Forums at ProgrammersHeaven.com

    Also this should be in the other forum (ooops.. I haven't seen the code yet)

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Well since it's cross-posted on other forums, then there's no reason for these threads.
    Too much demanding, not enough effort.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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