Ask a Question related to Mac Programming, Design and Development.
-
Tom Prayne #1
Simple newbie programs and PB
Hi,
I'm just starting to learn C. I have lots of fun doing so, but I ask
myself (resp: you :-)) if the following is possible:
At the moment I create my projects in PB, using the "standard c tool"
template. I compile the programs and launch them via the terminal.
My programs interact with the user by printf() and scanf().
If I run programs that don't take any user input (scanf), I can run them
from PB, a window opens and shows my printf() output. Fine.
But this doesn't work with scanf()... does anybody know if there is
something easy I can do about this? Is there a possibility to get text
input from that PB window?
It would be great if I could run my programs from PB, not the terminal,
because of debugging...
thanks in advance :-)
Tom
Tom Prayne Guest
-
Simple Newbie question
I am comtemplating learning flash, but since I will NEVER let ms windows near my harddrive again, I wanted to know if there is a way to write flash... -
LWP:Simple/LWP:UserAgent (newbie)
Hello, To start off with I need to explain that I am definately a novice at using Perl. I have inherited a couple of access databases that call on... -
Simple Question for a newbie
I have a flash animation with buttons, which will reside inside a web page. How do I call other pages within the website from each button? For... -
Simple problem help for newbie
Hi there, Just getting new to php, and have been making a script to interface with a simple mysql database but have been having problems with... -
Simple Newbie Questions
Hello, all... I'm trying to get started with Informix under Linux (RedHat 7.3, if it matters). I've got lots of experience with other database... -
Tom Harrington #2
Re: Simple newbie programs and PB
In article <20030924194107111+0200@sphynxxengine.com>,
Tom Prayne <tomprayne@gmx.de> wrote:
I think you'll have to use the command line. As far as debugging goes,> Hi,
>
> I'm just starting to learn C. I have lots of fun doing so, but I ask
> myself (resp: you :-)) if the following is possible:
>
> At the moment I create my projects in PB, using the "standard c tool"
> template. I compile the programs and launch them via the terminal.
> My programs interact with the user by printf() and scanf().
> If I run programs that don't take any user input (scanf), I can run them
> from PB, a window opens and shows my printf() output. Fine.
> But this doesn't work with scanf()... does anybody know if there is
> something easy I can do about this? Is there a possibility to get text
> input from that PB window?
>
> It would be great if I could run my programs from PB, not the terminal,
> because of debugging...
learning to use gdb at the command line is an extremely useful skill,
and even the basics of it will be worth the time it takes.
--
Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 1.4: Best cleanup yet, gets files other tools miss.
See [url]http://www.atomicbird.com/[/url]
Tom Harrington Guest
-
Uli Kusterer #3
Re: Simple newbie programs and PB
In article <20030924194107111+0200@sphynxxengine.com>,
Tom Prayne <tomprayne@gmx.de> wrote:
There are two tabs in the console window in PB: "Console" and "StdOut"> I can run them
> from PB, a window opens and shows my printf() output. Fine.
> But this doesn't work with scanf()... does anybody know if there is
> something easy I can do about this? Is there a possibility to get text
> input from that PB window?
(or something like that). Console is the GDB (debugger) console, but
"StdOut" is the actual terminal, which should work just fine for
entering text.
Cheers,
-- Uli
[url]http://www.zathras.de[/url]
Uli Kusterer Guest
-
Jim Schimpf #4
Re: Simple newbie programs and PB
Tom Prayne <tomprayne@gmx.de> wrote in message news:<20030924194107111+0200@sphynxxengine.com>...
If you don't put in any breakpoints and run debug in PB (i.e.> Hi,
>
> I'm just starting to learn C. I have lots of fun doing so, but I ask
> myself (resp: you :-)) if the following is possible:
>
> At the moment I create my projects in PB, using the "standard c tool"
> template. I compile the programs and launch them via the terminal.
> My programs interact with the user by printf() and scanf().
> If I run programs that don't take any user input (scanf), I can run them
> from PB, a window opens and shows my printf() output. Fine.
> But this doesn't work with scanf()... does anybody know if there is
> something easy I can do about this? Is there a possibility to get text
> input from that PB window?
>
> It would be great if I could run my programs from PB, not the terminal,
> because of debugging...
>
>
> thanks in advance :-)
>
> Tom
click on the hammer/spray can) it will bring up a debug window. Then
if you click on the Standard I/O tab in the upper part of the screen
you will have the same I/O you have when you run it in a window. The
other tab Console show you the same output you get with printf() but
doesn't take input to the program only commands to the debugger.
Next, I wouldn't use scanf() for input. It doesn't do much
checking and doesn't give you much freedom. I would suggest doing
something like this:
char in[64];
int someval;
char *ptr;
:
:
someval = DEFAULT_VALUE; // Set it equal to a default
value
printf("Input Someval: ") // Ask the user for
input
ptr = fgets(in,64,stdin); // Get input data
(allowing line editing)
if( ptr != NULL ) // Did the user
input something
{
someval = strtol(in,NULL,0); // Convert the input value
to a #
// Note this
will handle octal,decimal or Hex input
}
:
:
This way allows line editing, prevents buffer overflows and
will handle multiple styles of
number input.
--jim
Jim Schimpf Guest



Reply With Quote

