Simple newbie programs and PB

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: Simple newbie programs and PB

    In article <20030924194107111+0200@sphynxxengine.com>,
    Tom Prayne <tomprayne@gmx.de> wrote:
    > 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...
    I think you'll have to use the command line. As far as debugging goes,
    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

  4. #3

    Default Re: Simple newbie programs and PB

    In article <20030924194107111+0200@sphynxxengine.com>,
    Tom Prayne <tomprayne@gmx.de> wrote:
    > 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?
    There are two tabs in the console window in PB: "Console" and "StdOut"
    (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

  5. #4

    Default Re: Simple newbie programs and PB

    Tom Prayne <tomprayne@gmx.de> wrote in message news:<20030924194107111+0200@sphynxxengine.com>...
    > 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
    If you don't put in any breakpoints and run debug in PB (i.e.
    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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139