can someone help a complete beginner with Borland C++

Started by
7 comments, last by Soul On Ice 22 years, 9 months ago
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.
Advertisement
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
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. (c)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
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...

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.
So you are learning C++ with the book "C++ from scratch?"
instead of
#include
int main()
{
std::cout << "Decryptix. (c)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 << "...";
....
}
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
yep I used it. It gives you a good grounding in C++ and everything you learn is adapted to game programming.

This topic is closed to new replies.

Advertisement