Thread: can't capture the input

  1. #1
    Registered User
    Join Date
    Dec 2012

    can't capture the input

    I enter the value , but the program doesn't capture the value
    what's the problem ?

    struct book
    	float fPrice;
    	int iNumPages;
    	int iYear;
    void get_details( float* , int*, int* );
    int main()
    	struct book sMybook = { 25.50 , 690 , 2005};
    	struct book sHerbook;
    	float fdiff;
    	float x;
    	int y, z;
    	get_details( &x ,&y ,&z);
    	printf("My book :\n");
    	printf("%.2f\t%d\t%d\n", sMybook.fPrice, sMybook.iNumPages, sMybook.iYear );
    	printf("Her book :\n");
    	printf("%.2f\t%d\t%d\n", sHerbook.fPrice, sHerbook.iNumPages, sHerbook.iYear);
    	fdiff = sMybook.fPrice - sHerbook.fPrice; 
    	printf("the difference in price is %.4f\n", fdiff );
    	if (sMybook.iYear > sHerbook.iYear )
    		printf("Mine is greatest ");
    		printf("Her's is greatest");
    	return 0;
    void get_details( float*a , int*b , int*c ) 
    	printf("enter book price:\n");
    	scanf("%f", a);
    	printf("Enter number of pages:\n");
    	scanf("%d", b);
    	printf("Enter year:\n");
    	scanf("%d", c );

    someone please correct me
    Thank you !

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > get_details( &x ,&y ,&z);
    > x=sHerbook.fPrice;
    > y=sHerbook.iNumPages;
    > z=sHerbook.iYear;

    Perhaps you meant
    sHerbook.fPrice = x;

    Perhaps you could also do
    get_details( &sHerbook.fPrice ,&sHerbook.iNumPages ,&sHerbook.iYear);
    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.

  3. #3
    Registered User
    Join Date
    Dec 2012
    oh I see ..
    Thank you very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Capture line in input and get frequency
    By _izua_ in forum Windows Programming
    Replies: 2
    Last Post: 07-05-2008, 05:31 AM
  2. Window capture
    By tallubko in forum Windows Programming
    Replies: 12
    Last Post: 12-04-2007, 11:44 AM
  3. How to capture password in c
    By dan_track in forum C Programming
    Replies: 3
    Last Post: 03-13-2006, 06:41 AM
  4. Is this possible?? Can I capture a mac address?
    By kmineau in forum C++ Programming
    Replies: 0
    Last Post: 11-14-2002, 10:43 AM
  5. Capture a Picture
    By al.harris in forum C++ Programming
    Replies: 1
    Last Post: 02-20-2002, 09:57 PM