error:unterminated character constant

This is a discussion on error:unterminated character constant within the C Programming forums, part of the General Programming Boards category; 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() ...

  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,444
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,442
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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,444
    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, 07:52 AM
  2. warning: multi-character character constant
    By aadil7 in forum C Programming
    Replies: 2
    Last Post: 12-12-2010, 09: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, 04:10 AM
  5. Character handling help
    By vandalay in forum C Programming
    Replies: 18
    Last Post: 03-29-2004, 04:32 PM

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