Thread: New Programmer main () syntax error

  1. #1
    Registered User Bassglider's Avatar
    Join Date
    Nov 2007
    Posts
    32

    New Programmer main () syntax error

    i keep getting this error in debugger, im copying the code exactly from a book, I was wondering if it is my Turbo C++, Me or the Code I'm copying?

    Thanks in advance!

    Bassglider

    Statement mising ; in function main ()
    expression syntax in function main()

    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <ctype.h>
    #include <string.h>
    
    main()
    {
           char name[25], nameNew[25];
           char ans;
           int i;
           printf("What is your name? ");
           gets(name);
           printf("Are you sure that %s is your name? y or no", name);
           ans = getch();
           if (toupper(ans) == 'Y')
               { for (i = 0; i <= strlen(name); i++)
                   { nameNew[i]} = toupper(name[i]a); }
               printf ("Your name in uppercase letters is %s.\n", nameNew);
               }
           return 0;
    }

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    { nameNew[i]} = toupper(name[i]a); }
    Anything odd there that you see?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    If you indent your code properly, mistakes like that won't happen.

  4. #4
    Registered User Bassglider's Avatar
    Join Date
    Nov 2007
    Posts
    32
    Awww, I can't believe I didn't see that! Thank you, problem fixed. Hoping my eyes will adjust to reading this soon!

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Read the FAQ on using gets() - in other words, NEVER!
    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. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  3. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  4. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM