TEXT PAD FOR C PROGRAMMING ASAP PLEASE !thx

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
ak
Posts: 1
Joined: Thu Sep 18, 2003 3:08 pm

TEXT PAD FOR C PROGRAMMING ASAP PLEASE !thx

Post by ak »

IVE LEARNT JAVA USING TEXT PAD...but i wanna know how to use c over text pad....i've dowloaded the compiler off borland and stuff...now i just dled txt pad...what things do i need to do ...to transfer over....i want it to compile the C script and not try to compile it as a java script is there an option to toggle this??? and what steps do i need to do...details please...thx
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

mo
Posts: 306
Joined: Tue Mar 11, 2003 1:40 am

Post by mo »

Hope you don't mind my riding along on this one too!

Very first few pages learner here!

I have managed to set up TextPad to compile, and to run the program in DEBUG mode per the help files and the link above. I am having a little grief just running the program per the help files. What is happening is that a command window (Windows 2K Pro) is being opened, and I am being prompted for the information I am suppoed to enter, then the Command window presumably completes the work of the program and exits so quickly that I cannot see the result.

Here is the little first program that I am running (as soon as I put in the correct answer...zap the command window is closed. I would like it to remain open until I close it.:

Code: Select all

#include <iostream>
using namespace std;

int main()
{
   short Secret;
   short Guess;

   Secret = 3;

   cout << "try to guess my number. Hint: It's from 0 to 9"<<endl;
   cin >> Guess;

   while ( Guess != Secret)
   {
   cout << "Sorry, that's not correct."<<endl;
   cin >> Guess;
   }

   cout << "You guessed right!"<<endl;

   return 0;
}
Best Wishes!
Mike Olds
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Doesn't this belong in Java forum?
===================================
Ignore this.....my error (thanks MudGuard)....Sorry about that.
Hmmmm, why can't I delete this?
Bottom of forum says I can but..........?
Last edited by Bob Hansen on Thu Sep 18, 2003 11:09 pm, edited 4 times in total.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

No, as it is about C/C++...
mo
Posts: 306
Joined: Tue Mar 11, 2003 1:40 am

Post by mo »

I think this BB allows delete until someone has answered. Then you need to be sneeky and come in with some entirely different text and pretend you never said what someone thought they saw you say. Deny Deny Deny...
Best Wishes!
Mike Olds
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Hey Mo,
I'll be happy to field this one. Your program is executing exactly as it should--- It collects your input until you hit the correct condition. It prints a final message and exits. What you need to do is force the program to pause before it exists. I don't have Borland installed on this machine any more but there ought to be a getch() function which simply gets a single character from standard in (stdin). If it doesn't exist and I can't recall which library it'd be in (my C++ book is gathering dust somewhere in this room) you can code up the functionality quite simply.

Option 1

Code: Select all

   cout << "You guessed right!"<<endl; 
   getch(); // pause the program to see the output.
   return 0; 
} 
Option 2

Code: Select all

   cout << "You guessed right!"<<endl; 
   char dummy;
   cin >> dummy;  //pause program to see the output
   return 0; 
} 
[edit]
If this is pure C, I believe the declaration in Option 2 will have to come before the assignment of Secret's value.
[/edit]
I choose to fight with a sack of angry cats.
mo
Posts: 306
Joined: Tue Mar 11, 2003 1:40 am

Post by mo »

Thanks Tallyrand,

I'm glad to hear I have TextPad set up properly and to learn that trick. Using the Windows Command Prompt in W2K is a lot of extra typing I don't need and also does not work the same way as a terminal window on Linux so I end up doing things twice (or more often)...energy I could spend actually learning something.

mo

EDIT: This is what I settled on (put in my clip library):

Code: Select all

int main()
{
   short Dummy;
   
   Dummy = 0;

   cout << "Waiting for you to shut down with \"0\", Dummy."<<endl;
   cin >> Dummy;
   return 0;
}
Best Wishes!
Mike Olds
Post Reply