program is not working can someone help

program is not working can someone help

Post by azusa on Wed Aug 06, 2008 1:57 am
([msg=8930]see program is not working can someone help[/msg])

Hello I am teaching myself C from a C for dummies book and its this program they gave us to write out. I copied correctly from the book but I am still getting errors I also double checked and nothing can someone check it out for me and tell me what I am missing.


#include <stdio.h>

int main()
{
char adjective[20];
char food[20];
char chore[20];
char furniture[20];

/* Get the words to use in the madlib */

printf("Enter and adjective:"); /*prompt*/
scanf("%s",&adjective); /*input*/
printf("Enter a food:");
scanf("%s",&food);
printf("Enter a household chore(past tense);");
scanf("%s",&chore);
printf("Enter an item of furniture:");
scanf("%s",&furniture);

/*Display the output*/

printf("\n\nDon't touch that %s %s!\n",adjective,food);
printf("I just %s the %s!\n",chore,funiture);

return(0);
}



thanks in advanced
azusa
New User
New User
 
Posts: 22
Joined: Sun Aug 03, 2008 2:27 am
Blog: View Blog (0)


Re: program is not working can someone help

Post by BhaaL on Wed Aug 06, 2008 5:08 am
([msg=8935]see Re: program is not working can someone help[/msg])

Looks fine to me, what errors do you get?
Possibly use [code] Tags next time aswell.
BhaaL
Poster
Poster
 
Posts: 270
Joined: Sun Apr 13, 2008 11:16 am
Blog: View Blog (0)


Re: program is not working can someone help

Post by Sharmz on Wed Aug 06, 2008 11:38 am
([msg=8952]see Re: program is not working can someone help[/msg])

Code: Select all
printf("I just %s the %s!\n",chore,funiture);


Furniture was spelled incorrectly....

Code: Select all
printf("I just %s the %s!\n",chore,furniture);


That will fix the program.

In addition, you might want to add a
Code: Select all
getchar();
at the end of your program because I didn't see my mad lib when I ran it.

Cool program though.
-Sharmz
"You must be the change you wish to see in the world."
-Mohandas Karamchand Gandhi
"Be nice to nerds. Chances are you'll end up working for one."
-Bill Gates
Sharmz
New User
New User
 
Posts: 41
Joined: Thu May 29, 2008 1:18 am
Blog: View Blog (0)


Re: program is not working can someone help

Post by azusa on Wed Aug 06, 2008 3:18 pm
([msg=8968]see Re: program is not working can someone help[/msg])

that helped out...sucks one misspelled word can throw everything off. I guess I need to stop program so late at night when I am tired lol.

thanks
azusa
New User
New User
 
Posts: 22
Joined: Sun Aug 03, 2008 2:27 am
Blog: View Blog (0)


Re: program is not working can someone help

Post by yourmysin on Mon Aug 11, 2008 1:48 pm
([msg=9387]see Re: program is not working can someone help[/msg])

Or use variables which you can spell ;)
A+, Network+, MCTS(70-620), Security+, CCNA
yourmysin
Experienced User
Experienced User
 
Posts: 84
Joined: Mon Apr 21, 2008 9:02 pm
Location: Newport, Maine, USA
Blog: View Blog (0)



Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests