build fail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • codecrack
    New Member
    • Aug 2015
    • 1

    build fail

    i'm just learning programming from a book but i don't know why it always fails to build.
    Code:
    #include <stdio.h>
    #include <ctype.h>
    #include <conio.h>
    int main()
     {
    
     char letter;   												 // Letter typed by the user
    
       printf("Do you want to continue?\ (Y/N): ");
    
       letter = getch();         								 // Get the letter
       letter = toupper(letter);  							 // Convert letter to uppercase
    
       while ((letter != 'Y') && (letter != 'N'))
         {
           putch(7);      			      			      // Beep the speaker
           letter = getch();      			 			   // Get the letter
           letter = toupper(letter);						   // Convert letter to uppercase
         }
    
       printf("\n Your response was %c \n", letter);
      }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    This code:

    Code:
    printf("Do you want to continue?\ (Y/N): ");
    should look like:
    Code:
    printf("Do you want to continue? (Y/N): ");
    That \ in the original version is the escape sequence. It tells the compiler that the character following the \ is a escape sequence character. Like \n where the n means "newline".

    There is no \(, hence the error.

    Comment

    Working...