Thread: What's wrong with my compiler?

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    2

    What's wrong with my compiler?

    This is really frustrating. I tried to do even the simplest of variable assignments and I get this:

    Error: C:\TCI\test.c 6: Expression syntax in function main

    Can someone guide me through how to troubleshoot this please?

    Here's the code:

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    void main(void) {
    	clrscr();
            char abc='a';
    	printf("hello world");
    	getch();
    }
    I'm using borland turbo C, forgot which version. It's the one they have available for free download on their site.
    Thanks in advance
    Last edited by peroxide; 11-21-2006 at 07:35 PM.

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    19
    I'm not sure but I think all variable declarations must come first in the body of the function, hence abc has to be declared before you invoke clrscr()

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    2
    OH! Damn I just read the entry on the main site.. Thanks!

    Is it just me or does anyone else think that this is a really cumbersome way?

  4. #4
    Registered User vddking2's Avatar
    Join Date
    Nov 2006
    Location
    Vietnam
    Posts
    12
    I never seen this function void main(void) :-p

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by jalnewbie
    I'm not sure but I think all variable declarations must come first in the body of the function, hence abc has to be declared before you invoke clrscr()
    Correct. With such an old compiler, you are not allowed to have mixed declarations. C99 allows for this. Very few compilers actually support C99, but more will allow mixed declarations through compiler specific extensions.
    Quote Originally Posted by peroxide
    Is it just me or does anyone else think that this is a really cumbersome way?
    I find code with mixed declarations ugly and annoying to read.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    I thought borland had updated turbo C. Perhaps I am wrong, I have never really used their products. My friend however does use Borland Studio 2006, which is pretty good
    Double Helix STL

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    They may have updated it, but at last check, it wouldn't be the free one. They have their museum of old fossils, and I think the latest you can get is Borland 5, the command line version only. Neither of which are C99 compliant. Since their folder is named "TC"-something, it's likely Turbo C 3.x or older.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. compiler differences
    By white in forum C Programming
    Replies: 1
    Last Post: 02-18-2005, 02:58 PM
  3. Comile problem using latest Dev C++ Compiler
    By shiny_dico_ball in forum C++ Programming
    Replies: 6
    Last Post: 06-06-2003, 05:32 PM
  4. C Compiler
    By SAMSEIED in forum C Programming
    Replies: 5
    Last Post: 06-06-2002, 05:44 PM
  5. What's wrong with Micorsoft Visual C++?
    By knave in forum C++ Programming
    Replies: 9
    Last Post: 10-04-2001, 08:02 AM