Thread: Switching from Borland To Microsoft

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    14

    Switching from Borland To Microsoft

    Im a very beginner coder and I used Borland C++ BuilderX to write a program. Since C++ BuilderX doesnt do GUI stuff(But is awesome for writing code) I downloaded Microsoft Visual C++ Express which is great for the GUI stuff. Now when I try to include my BuilderX coded program in Visual C++ I get a boatload of errors, there were no errors in BuilderX. I think most of the errors are related to ifstream and sprintf.

    heres some snippets of how I coded it

    Code:
    #include <fstream.h>
    #include <stdio.h>
    #include <conio.h>
    #include <iostream.h>
    #include <stdlib.h>
    
    
    ifstream logfile( "1000.csv" );
    char log[] = "file.bin";
    
    ...
    
    logfile.getline(buffer, 250);
    
    ...
    
    fstream outbin(log, ios::out|ios::in|ios::binary);
    
    ...
    
    outbin.seekp(0x00000932);
    
    ...
    
    outbin.put(BinOut[i][n]);
    
    ...
    
    sprintf(del,",");
    In the program I deal with 2 files and I used different methods to open each, on the one I used ifstream and the other I used fstream. Im very new to this stuff so I dont know what a lot of this means but I figure stuff out as I go and the program works in a C++ BuilderX console setup.
    Last edited by Stringer; 10-12-2006 at 04:26 PM.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Your builder seems to be ancient, that code is pre-1998 C++ (i.e. before the very first C++ standard).

    Code:
    #include <fstream>
    #include <cstdio>
    #include <conio.h>  // This is not standard C++
    #include <iostream>
    #include <cstdlib>
    
    using namespace std; // This is pretty bad form, but probably better than tracking down the hundreds of errors.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    You may need to convert over to the standard headers:
    Code:
    #include <fstream>
    #include <cstdio>
    #include <conio.h>
    #include <iostream>
    #include <cstdlib>
    using namespace std;
    I don't think Microsoft Visual C++ Express has a conio.h though.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    14
    i tried the "using namespace std" already and I just got this

    File1.cpp(7) : error C2871: 'std' : a namespace with this name does not exist


    am I allowed to post my whole source? its like 263 lines long

    also I put the includes in so thats probably why they are weird, i read "learn C++ in 21 days" and it said to use those
    Last edited by Stringer; 10-12-2006 at 04:20 PM.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You need to drop the .h from your C++ headers file, too. (That excludes <conio.h>.) Read swoopy's post more carefully.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    14
    I tried the includes that swoopy posted and it didnt work, among the 37 errors I am getting

    .\File1.cpp(7) : error C2871: 'std' : a namespace with this name does not exist
    .\File1.cpp(12) : error C2146: syntax error : missing ';' before identifier 'logfile'

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    14
    heres my whole program that I made in BuilderX with the includes that swoopy posted
    Last edited by Stringer; 10-12-2006 at 06:19 PM.

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    You don't need pre-compiled headers. Go to the project options or properties and find the pre-compiled headers option and turn it off, then delete the #include "stdafx.h" line. When you create a new project, choose Win32 Console Application and check the Empty Project box on one of the tabs in the wizard to make sure that it isn't set in the future.

    The problem is that the compiler ignores everything before the #include "stdafx.h", so if you use that you need to put it first.

  9. #9
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You're missing a double quote after stdafx.h:
    Code:
    #include <fstream>
    #include <cstdio>
    #include <conio.h>
    #include <iostream>
    #include <cstdlib>
    #include "stdafx.h"
    using namespace std;
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  10. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    14
    ok that worked, thanks!

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. Apps that act "differently" in XP SP2
    By Stan100 in forum Tech Board
    Replies: 6
    Last Post: 08-16-2004, 10:38 PM
  3. Another Microsoft joke
    By Panopticon in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 02-02-2003, 12:53 PM
  4. Microsoft rulling
    By Sentaku senshi in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-02-2002, 03:50 AM
  5. Retaliation towards witch king\microsoft
    By Koshare in forum Linux Programming
    Replies: 7
    Last Post: 10-19-2001, 04:54 AM