Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(Borland C++) ¦¦ (Borland C++ Builder)

Status
Not open for further replies.

skia

Programmer
Feb 1, 2002
9
0
0
GR
Hello i'am a rookie here.

Which of the 2 is the best?

Which should i prefer and why?

Thank you!
 
Builder is a Rapid Application Development (RAD) program. That means it is easy to build Windows based programs. You just drag and drop the different components. Then you can write the code you want for the components and compile.

C++ is just the compiler and linker.

C++ version 5.5 is the SAME compiler that Builder 5 uses. Builder just makes it easier to use. The compiler is free, Builder co$t$.
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Thanks Very much!

Another problem i have is the following!

a) How can i deactivate Ctrl-Break and Ctrl-Alt-Delete in my C++ program so that the user who runs it cannot break it,escape from it or close it?

b) How does the following won't work in C++ Builder?

char s[11];

s=Edit1-Text;

c) How can i write a string to a Label1.Caption letter-by-letter? Is it possible to write directly to the form and not to the Label component?

d) Why this doesn't work?
if ((kbhit() && getch())==27) printf("You've hust hit Escape!");

e) Why tis doesn't work?
f ((f=fopen("C:\\DataBase.txt", "r"))==NULL)
cprintf("To arxeio C:\\DataBase.txt den mporese na anoixtei gia diavasma!\a");
else
{
while ((s[k++]=getch())!=27)
{
clrscr(); fseek(f, 0, SEEK_SET); i=0;

while (fscanf(f, "%s %s %s", filos.onoma, filos.eponymo, filos.til)!=EOF)
if (strstr(filos.onoma, s))
{
cprintf("%-15s%-20s%-15s\r\n", filos.onoma, filos.eponymo, filos.til);
i++;
}

if (i==0)
cprintf("No record found! Pata (Esc)...\a");
else
cprintf("\nFound %d record(s)!", i);
}
}

I want the program to when the user press keys to find them searching te field of the record starting from the beginning.

Fo example if the record is "Nikos" if the user presses N to show Nagia
Nikos
Nikitas
If it follows by an i
to show Nikos
Nikitas
if Niko only Nikos

What cahnges do i have to make?

Thanks very much and sorry for the too much questions

I appreciate your help!

 
Sorry it has taken me some time to get back to you. I've been very busy at work. I haven't had time to research all your questions but here are some answers off the top of my head...

a) How can i deactivate Ctrl-Break and Ctrl-Alt-Delete in my C++ program so that the user who runs it cannot break it,escape from it or close it?
See
b) How does the following won't work in C++ Builder?
char s[11];
s=Edit1-Text;

I assume you mean s=Edit1->Text. There are several reasons. Borland's text boxes are AnsiStrings not character arrays. AFAIK, you cannot assign one character array to another with the = sign, you have to use something like strcpy. Only strings have the = sign overloaded for them. To assign a character array from a text box, you have to do something like:
Code:
char s[11];
AnsiString NewS = Edit1->Text;
int j = NewS.Length();
// If newS is too big, you will a buffer overrun (DANGEROUS)
if (j <= 10)
  strcpy(s, News.c_str());
Note that I check for a length of 10 since a character array always needs one place for the terminating character.

c) How can i write a string to a Label1.Caption letter-by-letter?
Your best bet is to put the characters to a string one by one and the put the string into the caption between each input of the letter.
Is it possible to write directly to the form and not to the Label component?Maybe but it might be more work that it is worth. I just don't know for certain.

d) Why this doesn't work?
if ((kbhit() && getch())==27) printf(&quot;You've hust hit Escape!&quot;);
e) Why tis doesn't work?
f ((f=fopen(&quot;C:\\DataBase.txt&quot;, &quot;r&quot;))==NULL)
cprintf(&quot;To arxeio C:\\DataBase.txt den mporese na anoixtei gia diavasma!\a&quot;);
else
{
while ((s[k++]=getch())!=27)
{
clrscr(); fseek(f, 0, SEEK_SET); i=0;

while (fscanf(f, &quot;%s %s %s&quot;, filos.onoma, filos.eponymo, filos.til)!=EOF)
if (strstr(filos.onoma, s))
{
cprintf(&quot;%-15s%-20s%-15s\r\n&quot;, filos.onoma, filos.eponymo, filos.til);
i++;
}

if (i==0)
cprintf(&quot;No record found! Pata (Esc)...\a&quot;);
else
cprintf(&quot;\nFound %d record(s)!&quot;, i);
}
}

Are you trying to use this in a Windows GUI app? My notes on kbhit and getch is that you should not use these in Win32 GUI apps.

If you are trying to do this on a console or DOS app, it should work. Hope this was helpful :) James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top