Thread: error:unterminated character constant

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

    error:unterminated character constant

    What is unterminated character constant error?

    here is the code that gives me that error:

    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    
    main()
    
    {
    	
    	
    	float a,b,c,x;
    	printf("Use this to work out the length of the hypotenuse on a right angled triangle.\n");
    	printf("Please enter a:");
    	scanf("%f",&a);
    	printf("\nPlease enter b:);
    	scanf("%f",&b);
    	
    	// a*a+b*b=c*c;
    	
    	x=a*a+b*b;
    	c=sqrt(x);
    	
    	printf("\nThe triangle's hypotenuse has a length of %f ",c);
    	
    	getch();
    	
    	return 0;
    }

    and the part compiler tells me where the error occurs:

    Code:
    printf("\nThe triangle's hypotenuse has a length of %f ",c);

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Look at line 14 where you ask for input b. This should stand out if you're using an editor that does syntax highlighting. If you're not, then you should start using such an editor. Many editors can do this, and it's great for spotting such mistakes.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    20
    Thanks,anduril462.Which compiler do you suggest me?I am using C-free.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    And if you haven't got a decent code editor, then get into the habit of typing in the balancing character, then moving the cursor.

    Eg.
    printf("");

    followed by cursor-left 3 times, becomes
    printf("hello world");

    Ditto for comments, braces, parentheses.
    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.

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    20
    Thanks for the advice,Salem.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    If you mean which editor do I suggest: C-Free is fine. It's an IDE with an editor that does syntax highlighting (at least in the newest version). I've never used it before, so you may need to change some options to make it work or upgrade if your version doesn't support it.

    If you actually want a compiler recommendation to use with C-free, I would suggest MinGW, which is a free Windows port of GCC. Many people here use it and like it.

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    20
    C-free does highligthning but it doesn't show where the error is,properly.I'll try that MinGw.Thx.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stuck making part of my code work for testing input
    By KevinP in forum C Programming
    Replies: 6
    Last Post: 01-25-2011, 08:52 AM
  2. warning: multi-character character constant
    By aadil7 in forum C Programming
    Replies: 2
    Last Post: 12-12-2010, 10:02 PM
  3. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  4. get wide character and multibyte character value
    By George2 in forum C++ Programming
    Replies: 27
    Last Post: 01-27-2008, 05:10 AM
  5. Character handling help
    By vandalay in forum C Programming
    Replies: 18
    Last Post: 03-29-2004, 05:32 PM