Thread: Different syntax with different compilers?

  1. #1
    voodoo
    Guest

    Different syntax with different compilers?

    I starting a new job soon doing mainly VBA and VB programming. However the company wants me to start studying C++ as they use it on a Unix platform.

    I downloaded the Borland compiler (I also have Visual C++) and have been looking at the tutorials on this site, which seem excellent. Anyway I am noticing a few syntac differences and wanted to know how different the syntax for Borland is to what I will be using on a Unix platform.

    For example to send text to the screen in the tutorials it looks like

    cout<<"HEY, you, I'm alive! Oh, and Hello World!";

    where as with Borland I would use

    printf("HEY, you, I'm alive! Oh, and Hello World!");

    This is just a small thing but I was wondering if there are many similar differences.

    As my company is using a Unix platform I presume the syntac would be more like the first example (using cout<<). I would prefer to get practice on a Unix environment but I do not have Unix installed on my PC.

    Is their a better compiler to use such as DJGPP that mimicks Unix ( I did look at downloading DJGPP but it seemed very complicated).

    Any advice on this? Are the differences very significant between Borland and Unix? And is there a better compiler I should use to mimick Unix?

    Regards

    voodoo

  2. #2
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    you can use cout with borland...

    cout = C++

    printf = C

    cout is a standard C++ function to standard output
    Blue

  3. #3
    voodoo
    Guest

    Quick reply

    Wow that was fast, thanks for the quick reply.

    I see now how I can make the cout work - I needed to include iostream.h

    Now more to the general topic of my thread would then be any real differences in syntax or usage between what I write for programs on Borland and what would be used on Unix environment?

    I would like to know that the programs I write and syntax I learn on my own PC using Borland would be easily transferabe to a Unix environment. And am I better using some othe compiler that more closely simulates the Unix environment? Unfortunately I dont have much experience with Unix and am trying to prepare for any surprises or significant differences.

    Any advice would be greatly appreciated.

    voodoo

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >any real differences in syntax or usage between what I write
    It depends on what you're doing. If you use all ISO C++ compliant classes and functions then your program will run on any system that supports C++. If you use anything nonstandard or implementation dependant then chances are good your program will break under UNIX. The same goes for a program originally coded in the UNIX environment.

    -Prelude
    My best code is written with the delete key.

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    >where as with Borland I would use
    >printf("HEY, you, I'm alive! Oh, and Hello World!");

    If you downloaded Borland C++ or C++Builder, then cout should also work. The function printf is originally from C where cout was introduced with C++.

    >I would like to know that the programs I write and syntax I
    >learn on my own PC using Borland would be easily transferabe
    >to a Unix environment.

    All compilers should support the C++ standard, I know that some of them support just a subset and most of them extend the standard. But I would recommend to learn ANSI C++ and keep away from the manufacturer specific changes to C++.

    For years ago I've been using Turbo C and noticed that Microsoft C didn't always compile it and vice versa. And in that way I've learned to use ANSI C.

    Though ofcourse there are platform dependent libraries which you probabably need to use for your applications.

    >And am I better using some othe compiler that more closely
    >simulates the Unix environment?

    A compiler that simulates an OS? :-)

    I can recommend GCC, it has also a C++ compiler. I use GCC on several OS'es and it still fits my needs. And it is the same on each platform. GCC on Unix works just the same as GCC on Windows or a different platform.

    >Unfortunately I dont have much experience with Unix and am
    >trying to prepare for any surprises or significant differences.

    When using ANSI C++, there shouldn't be too much surprises.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM