Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > how to use stdin with Project Builder?

how to use stdin with Project Builder?
Thread Tools
Mac Elite
Join Date: Sep 2000
Location: New York
Status: Offline
Reply With Quote
Feb 21, 2002, 10:56 PM
 
I'm new to project builder. I used it last week for a computer science assignment. A guy who knew how to use Microsoft Visual Studio helped me figure it out, since I don't know how to use any IDE, and I really needed a debugger. That assignment didn't require anything from stdin, since it was just the implementation of the standard C library. However I found the debugger to be EXTREMELY helpful.

Now I have a project that requires a file as stdin and I don't know how to get that to happen in project builder. In the terminal I would just type <font face = "courier">cc source.c</font> and then <font face = "courier">a.out &lt; inputfile</font>

What's the equivalent in project builder? I really would like this so that i can use the debugger. Thanks.
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Feb 22, 2002, 09:12 AM
 
You should probably use the terminal if you're going to use stdin or even complex stdout in your program. Just build the program and launch it normally from the terminal, or with gdb, which is the same thing as PB's debugger. I'm not sure if you can redirect certain things to stdin when launched in PB.
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Mac Elite
Join Date: Sep 2000
Location: New York
Status: Offline
Reply With Quote
Feb 23, 2002, 04:27 PM
 
i've been using the terminal but i like using the graphical debugger in project builder. I'm supposed to know how to use gdb but I don't know how. The class expects us to use emacs, gdb and make but I find project builder nicer.
     
Mac Elite
Join Date: Sep 2000
Location: New York
Status: Offline
Reply With Quote
Mar 6, 2002, 10:06 PM
 
I'm topping this thread because I need to be able to read in text files to my program through standard input and they're too big to cut and paste. I looked through the help files and it shows you how to set command line arguments but when I put in "&lt; inputfile.txt" it causes my program to crash at the beginning of my main function.

Does anyone know how to do this? I know I can run my program from the terminal but I want to be able to use the graphical debugger as well. I really don't know how to use gdb.

Thanks.
     
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status: Offline
Reply With Quote
Mar 6, 2002, 11:05 PM
 
I couldn't figure out how to do it in Project Builder. Could you read input from a file instead of stdin? If so then in Project Builder you can tell it what the command line arguements should be. Come to think of it, you might be able to put "&lt; file.txt" as the arguments.

To set the arguments for the debugger, select your target in the targets tab on the left side. Then select the executables tab on the right bottom.

If that doesn't work, you can use gdb, which isn't that hard.

It'd go something like this:

gdb program

run &lt; file.txt

When it crashes type "where" to see where the program is. "list" shows the source code. "break 42" sticks a breakpoint at line 42. If the program is running control-c will stop it.

For all those commands you can just type the first letter.

dave
     
Forum Regular
Join Date: Feb 2002
Location: Fort Lauderdale, Florida
Status: Offline
Reply With Quote
Mar 7, 2002, 10:48 AM
 
Originally posted by waffffffle:
<STRONG>i've been using the terminal but i like using the graphical debugger in project builder. I'm supposed to know how to use gdb but I don't know how. The class expects us to use emacs, gdb and make but I find project builder nicer.</STRONG>
Do yourself a favor and learn how to use emacs, gdb, and especially make. Odds are you will run into these things many times through the course of your career. I wish i would have when i was in college!
     
v8q
Junior Member
Join Date: Mar 2002
Status: Offline
Reply With Quote
Mar 11, 2002, 03:51 PM
 
If it was me, I think I would just look at the command line args, and if I got an input file name, just close the stdin file descriptor and re-open it with the file name. That is all you are trying to accomplish anyway with the redirect.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:08 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2