Jump to content

  • Log In with Google      Sign In   
  • Create Account


can someone help a complete beginner with Borland C++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Soul On Ice   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 July 2001 - 08:48 AM

I''ve just starting to learn programming from a book, i''ve written out a piece of code but when i try to run it the form appears blank. Can someone please tell me how i see the program running, its been compiled successfully and the code is right, i dont know what i''m doing wrong.

Sponsor:

#2 acraig   Members   -  Reputation: 471

Like
Likes
Like

Posted 05 July 2001 - 01:02 PM

quote:
Original post by Soul On Ice
I''ve just starting to learn programming from a book, i''ve written out a piece of code but when i try to run it the form appears blank. Can someone please tell me how i see the program running, its been compiled successfully and the code is right, i dont know what i''m doing wrong.


Need a little more information. What are you expecting to see? Are you using any sort of API (DirectDraw/OpenGL). What does the piece of code supposed to do?

-------
Andrew

#3 Soul On Ice   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 July 2001 - 09:31 PM

Heres the code:-



/---------------------------------------------------------------------------

#include
#pragma hdrstop

#include "Dectyptix.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)

{
}
//---------------------------------------------------------------------------
#include
int main()
{
std::cout << "Decryptix. ©copyright 1999 Liberty ";
std::cout << "Associates, Inc. Version 0.2\n";
std::cout << "There are two ways to play Decryptix: ";
std::cout << " either you can guess a pattern I create, ";
std::cout << "or i can guess your pattern.\n\n";

std::cout << "if you are guessing, I will think of a\n ";
std::cout << "pattern of letters (e.g., abcde).\n\n";

std::cout << "On each turn, you guess the pattern and\n";
std::cout << " i will tell you how many letters you \n";
std::cout << "got right, and how many of the correct\n";
std::cout << "letters were in the correct position.\n\n";

std::cout << "The goal is to decode the puzzle as quickly\n";
std::cout << "as possible. You control how many of the correct\n";
std::cout << "can be used andhow many positions\n";
std::cout << " (e.g., 5 possible letters in 4 positions) \n";
std::cout << "as well as whether or not the pattern might\n";
std::cout << " contain duplicate letters (e.g., abcde).\n\n";

std::cout << "If I''m guessing, you think of a pattern \n";
std::cout << "and score each of my answers.\n\n";

const int minLetters = 2;
const int maxLetters = 10;
const int minPositions = 3;
const int maxPositions = 10;

int howManyLetters = 0, howManyPositions = 0;
bool duplicatesAllowed = false;
int round = 1;

std::cout << "How many letters? (";
std::cout << minLetters << "-" << maxLetters << "): ";
std::cin >> howManyLetters;

std::cout << "How many positions? (";
std::cout << minPositions << "-" << maxPositions << "): ";
std::cin >> howManyPositions;

char choice;
std::cout << "Allow duplicates (y/n)? ";
std::cin >> choice;

return 0;

}


I''m not using any API, the code should display this information out asking the user amount of letters to use, the amount of positions and if duplicates are allowed.

Thanks for trying to help me

#4 Tassadar   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 July 2001 - 09:47 PM

What''s that shit above your own code? don''t tell me you wrote that yourself. As far as I can see from your code, you are writing a console app. You don''t need forms then. Open your CPP file with something like notepad, delete the code you didn''t write yourself, and compile it through a dos prompt with

bcc32 program1.cpp

Just that, where program1.cpp is the filename you saved your source file as. Then run your exe...


Now I hope you know how to use a dos-prompt, I don''t know the full c++ builder edition, only the free command line tools. It should be a setting somewhere when you check your project properties...


#5 Soul On Ice   Members   -  Reputation: 122

Like
Likes
Like

Posted 06 July 2001 - 10:09 PM

Thanks people, i''ve been able to sort out the problem now and Tassadar i didn''t write that bit of code it was already there.

#6 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 09 July 2001 - 05:03 AM

So you are learning C++ with the book "C++ from scratch?"

#7 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 09 July 2001 - 05:10 AM

instead of
#include
int main()
{
std::cout << "Decryptix. ©copyright 1999 Liberty ";
std::cout << "Associates, Inc. Version 0.2\n";
std::cout << "There are two ways to play Decryptix: ";
std::cout << " either you can guess a pattern I create, ";
std::cout << "or i can guess your pattern.\n\n";
....
}
write:

#include
using namespace std; //use namespaces to avoid writing std::cout

int main()
{
cout << "...";
....
}

#8 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 09 July 2001 - 06:07 AM

quote:
Original post by Anonymous Poster
So you are learning C++ with the book "C++ from scratch?"


yeah, it pretty good. Did you use it?

And about the namespace i got past that bit today

#9 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 09 July 2001 - 06:31 AM

yep I used it. It gives you a good grounding in C++ and everything you learn is adapted to game programming.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS