Thread: printf and scanf

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    4

    printf and scanf

    Code:
    void gather_info(char *bread, char *doubleLoaf, char *manualBake)
    {
    	printf("White or Sweet bread? (w/s) ");
    	scanf("%c", bread);
    
    	printf("\nDouble loaf? (y/n) ");
    	scanf("%c", doubleLoaf);
    
    	printf("\nManual bake? (y/n) ");
    	scanf("%c", manualBake);
    
    }
    
    void greeting(char *bread, char *doubleLoaf, char *manualBake)
    {
    	printf("The Bread Factory\n\n");
    	printf("I'm getting hungry, let's make some bread!\n\n");
    
    	gather_info(bread, doubleLoaf, manualBake);
    }
    
    
    ...
    greeting(&bread, &doubleLoaf, &manualBake);
    ...
    When I enter in anything for the first prompt White or Sweet bread? (w/s), both of the other prompts are printed simultaneously and I can only enter one more value... what's going on??

    Thanks!
    Last edited by Salem; 10-27-2008 at 11:11 PM. Reason: your one free code tag insert service - read the rules

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  3. Newb Help: Full Arrays and Functions
    By LycanGalen in forum C Programming
    Replies: 5
    Last Post: 01-31-2008, 08:35 PM
  4. Please help debug
    By Wexy in forum C Programming
    Replies: 2
    Last Post: 11-11-2002, 12:40 AM
  5. help with switch statements
    By Wexy in forum C Programming
    Replies: 3
    Last Post: 11-06-2002, 05:44 PM