cant solve my program's error

This is a discussion on cant solve my program's error within the C Programming forums, part of the General Programming Boards category; I'm a beginner !!I dono why illegal break error happen in this code!!! Code: void draw_triangle(){ while (1){ int scounter; ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    1

    cant solve my program's error

    I'm a beginner !!I dono why illegal break error happen in this code!!!

    Code:
    void draw_triangle(){
    
    	while (1){
    	int scounter;
    	int spacechar=32;
    	char starchar='*';
    	int hcounter;
    	int length;
    	
    	
    
    	printf("input height");
    	scanf("%d",&length);
    
    	if(length<=0){
    		printf(" the length is incorrect \n  input the correct height");
    		continue ;	}
    
    	int height = length/2 +1;
    
    	while (height>0){
    	
               
    		for (scounter=height-1 ; scounter>0 ; scounter--){
    
    		
    			printf("%c",spacechar);}
    		
    		for (hcounter=(length-2*(height-1)); hcounter>0; hcounter--){
    
    			printf("%c",starchar);
    		
    		}
    		
    		
    	
    		printf("\n");
    		height=height-1;
    	
    	}
    
    
    		printf("enjoy Ur choice");
    		printf("select Ur next choice");
    
    		
    
    }
    
    
    
    break;}

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,622
    You have a break statement at the end that should not be there.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21