Thread: Printline problem

  1. #1
    Divine
    Join Date
    Oct 2007
    Location
    Earth(duh!)
    Posts
    20

    Unhappy Printline problem

    I have written a complete coding for a program. The thing is when I run the program there is no line or whatsoever including the "bell" sound. Any idea why?

    (I'm using Dev C++)

    Code:
    /*Updating a Series of Customer Accounts(simplified billing system)*/
    
    #include <stdio.h>
    
    void readinput(int i);
    void writeoutput(int i);
    
    struct date{
    	int month;
    	int day;
    	int year;
    }date;
    
    
    struct account
    {
    	char name[40];
    	char street[40];
    	char city[40];
    	int acct_no;
        float previous_balance;
    	float current_payment;
    	float new_balance;
        struct date lastpayment;	
    }
    customer[]={1};
    
    void printline()
    {
    	int i;
    
    	for(i=0;i>20;i++)
    
    	{
    		printf("\7");
    		printf("\b");
    		printf("\32");
    		printf(" ");
    		printf("\13");
    		printf(" ");
    	}
    	printf("\n");
    
    }
    
    main()
    
    {
    	int i,n;
    
        printline();
        
    	printf("CUSTOMER BILLING SYSTEM\n\n");
    	
    	printline();
    
    	printf("\nHow many customer are there?");
    	scanf("%d",&n);
    
    	for(i=0;i<n;++i)
    
    
    	{
    		readinput(i);
    
    		customer[i].new_balance = customer[i].previous_balance - customer[i].current_payment;
    	}
    	
    	
        for(i=0;i<n;++i)
       
    	writeoutput(i);
     
    }
    
    void readinput(int i)
    
    {
    
    	printf("Customer no.%d\n",i+1);
    	
    	printf("\t\Name:");
        scanf("%s",&customer[i].name);
    
    	printf("\tStreet:");
        scanf("%s",&customer[i].street);
    
    	printf("\tCity:");
        scanf("%s",&customer[i].city);
    
    	printf("\tAccount number:");
    	scanf("%d",&customer[i].acct_no);
    
    	printf("\tPrevous Balance:");
    	scanf("%f",&customer[i].previous_balance);
    
    	printf("\tCurrent payment:");
    	scanf("%f",&customer[i].current_payment);
    
    	printf("\tPayment date (mm/dd/yyyy):");
    	scanf("%d%d%d",&customer[i].lastpayment.month,
    		           &customer[i].lastpayment.day,
    				   &customer[i].lastpayment.year);
    				   
        printline();
    	return;
    
    }		
    
    void writeoutput(int i)
    
    {
    	printf("\\tnName:%s",customer[i].name);
    
    	printf("\n\tAccount number:%d\n",customer[i].acct_no);
    
    	printf("\n\tStreet:%s\n",customer[i].street);
    
    	printf("\n\tCity:%s\n\n",customer[i].city);
    
    	printf("Previous Balance: %.2f",customer[i].previous_balance);
    
    	printf("   Current Payment: %.2f", customer[i].current_payment);
    
    	printf("   New balance: %.2f\n\n",customer[i].new_balance);
    
        return;
    	
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > printf("\7");
    It might sound the bell, but it's implementation-specific as to whether you will hear anything.

    > printf("\b");
    It's \a for the bell, \b is backspace.

    All of which is moot anyway, because
    for(i=0;i>20;i++)
    the for loop is trivially false since i doesn't start off being GREATER than 20.

    Code:
    customer[]={1};
    This doesn't declare a variable length array you can write 'n' customers into later on.
    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
    Divine
    Join Date
    Oct 2007
    Location
    Earth(duh!)
    Posts
    20
    wow thanks, it's working now. But when i execute the symbols tend to load very slow. Is there any way to make them load faster?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, each "beep" will take a few hundred milliseconds or so, so 20 times that will be a few seconds.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I guess you're about to learn that "beep" as an amusement lasts about 5 minutes before it becomes really annoying and then you only beep when you've got something really important to tell the user.

    Even then, many advanced users would want an option to permanently turn it off.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM