Thread: lil prob

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    34

    lil prob

    thanks for the help sunny n sly in the last post but salem locked it so i have to make a new one for the other problem... :/

    it works, but how to i get it to tell them what age they r if its not 17 ?

    ive got the name part to work just not the age, its annoying.

    plz let me know, thanks.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    I bet Salem would love to take you home and use you as target practice. You have like four other threads open in this forum less than a day old. STOP POSTING NEW ONES. I explained how to handle the name else statement. Age is no different.
    Sent from my iPadŽ

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well this posting frenzy must come from the name I suppose....

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    sorry for posting that many ill cut down heh.

    but it is different as it doesnt work... ?

    Code:
    the scanf( "%d" , age ); is right isnt it?
    if ( age == 17 ) {
    printf ( "im that age too\n" ); }
    
    else {
    printf ( "you are %d\n", age ); }
    
    this will not work it just says, you are and a double arrow char.

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Code:
     scanf ( "%d", &age );
    This symbol refers to the address of the variable. In the case of name, which is an array, the array name without an index already refers to the address.
    Last edited by SlyMaelstrom; 12-01-2005 at 12:04 PM.
    Sent from my iPadŽ

  6. #6
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    oh yeh i see sorry. i had the &name but i took it out because name didnt use one, didnt know arrays didnt need one. sorry.

    thankyou.

  7. #7
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    geez it still wont work. if i type in the age part, 60 it gives

    your age is 2293612

    whats the problem cuz the code looks good to me.. then again im a n00b.

  8. #8
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Oh that's my fault, copied the wrong line for the example.

    The & sign goes on the scanf variable not the printf variable.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 06:53 PM
  2. little prob with string?
    By ghostshadow189 in forum C++ Programming
    Replies: 6
    Last Post: 04-22-2007, 02:02 PM
  3. a lil help.. prog's done but wrong output
    By gamer4life687 in forum C++ Programming
    Replies: 5
    Last Post: 09-13-2005, 02:32 AM
  4. Clipping plane prob?
    By gazsux in forum Game Programming
    Replies: 7
    Last Post: 07-04-2003, 09:49 PM
  5. Photoshop prob
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 12-23-2002, 03:29 PM