Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #59119 > unrolled thread

Why this behavior?

Started bybilsch <king621@comcast.net>
First post2015-03-28 11:06 +0000
Last post2015-03-28 14:35 +0100
Articles 12 — 6 participants

Back to article view | Back to comp.lang.c


Contents

  Why this behavior? bilsch <king621@comcast.net> - 2015-03-28 11:06 +0000
    Re: Why this behavior? Richard Heathfield <rjh@cpax.org.uk> - 2015-03-28 11:16 +0000
      Re: Why this behavior? bilsch <king621@comcast.net> - 2015-03-28 11:22 +0000
        Re: Why this behavior? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-03-28 15:22 +0000
          Re: Why this behavior? Richard Heathfield <rjh@cpax.org.uk> - 2015-03-28 21:42 +0000
    Re: Why this behavior? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-03-28 05:53 -0700
      Re: Why this behavior? bilsch <king621@comcast.net> - 2015-03-28 15:39 +0000
        Re: Why this behavior? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-03-28 09:24 -0700
          Re: Why this behavior? bilsch <king621@comcast.net> - 2015-03-28 17:05 +0000
          Re: Why this behavior? bilsch <king621@comcast.net> - 2015-03-28 17:08 +0000
        Re: Why this behavior? Keith Thompson <kst-u@mib.org> - 2015-03-28 17:34 -0700
    Re: Why this behavior? Lőrinczy Zsigmond <nospam@for.me> - 2015-03-28 14:35 +0100

#59119 — Why this behavior?

Frombilsch <king621@comcast.net>
Date2015-03-28 11:06 +0000
SubjectWhy this behavior?
Message-ID<mf620e$sh7$1@dont-email.me>
This question is not related to a similar question I posted previously 
regarding command line arguments.  That problem is solved - this is 
different.   I made a program that draws Lissajous patterns (periodic 
graphs) using sine functions and exponential functions.  There are many 
parameters that affect the display of these graphs. There is 'front end' 
code that allows user to set these parameters using scanf.  This front 
end should query the user any time the program is started - indeed it 
does when the program is started from the command line.  I have an icon 
on my Ubuntu desktop that starts the program when you double click the 
icon - however when you do it that way none of the user querys are 
executed.  The program simply runs using the values initialized when the 
variables were declared. This behavior is a mystery to me. How does it 
skip over the front end code? I have another simpler program structured 
the same way and it has the same behavior when started by double clicking 
the icon.

TIA.   Bill S.

[toc] | [next] | [standalone]


#59120

FromRichard Heathfield <rjh@cpax.org.uk>
Date2015-03-28 11:16 +0000
Message-ID<mf62hg$68l$1@dont-email.me>
In reply to#59119
On 28/03/15 11:06, bilsch wrote:
> [...]  There is 'front end'
> code that allows user to set these parameters using scanf.  This front
> end should query the user any time the program is started - indeed it
> does when the program is started from the command line.  I have an icon
> on my Ubuntu desktop that starts the program when you double click the
> icon - however when you do it that way none of the user querys are
> executed.  The program simply runs using the values initialized when the
> variables were declared. [...]

I have a fairly good idea of what's wrong (not the specifics, just the 
general idea), and you'll need library-specific help for this one - SDL, 
I think you said before?

The only hint I'm going to give you (partly because this is off-topic 
but mostly because there is a very real danger that I am mistaken) is 
that I think your GUI interface has a replacement method for getting 
input from the user, and is not attached to any kind of console at which 
you might be able to type. You will have to write code to create a 
dialog of some kind.

In the absence of an SDL-specific newsgroup, try comp.unix.programmer 
(at least in the short term - they may well send you on somewhere else). 
What was that Linux group? I think it might be 
comp.os.linux.developer.applications or something like that. If you can 
find it, they might also be worth a try. (It doesn't matter whether 
you're using SDL on Linux or Windows. It's the library you need help 
with, not the OS, and they're the folks that are most likely to have SDL 
know-how.)

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#59122

Frombilsch <king621@comcast.net>
Date2015-03-28 11:22 +0000
Message-ID<mf62tv$sh7$2@dont-email.me>
In reply to#59120
There is an SDL forum where I am a member.  I'll try that first.  Thanks 
for the info. 
 Bill.

[toc] | [prev] | [next] | [standalone]


#59140

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2015-03-28 15:22 +0000
Message-ID<87wq216ta1.fsf@bsb.me.uk>
In reply to#59122
bilsch <king621@comcast.net> writes:

> There is an SDL forum where I am a member.  I'll try that first.  Thanks 
> for the info. 

I'd say SDL is way over the top for this.  I'd:

(a) make the program take commend-line arguments for the various
settings (search for getopt and/or getopt_long);

(b) install and use zenity (or, a bit more flexible, yad) and write a
simple shell script to run your program from the user-entered values.

comp.unix.programmer and comp.unix.shell would then be the pace to ask
more.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#59167

FromRichard Heathfield <rjh@cpax.org.uk>
Date2015-03-28 21:42 +0000
Message-ID<mf777d$os7$1@dont-email.me>
In reply to#59140
On 28/03/15 15:22, Ben Bacarisse wrote:
> bilsch <king621@comcast.net> writes:
>
>> There is an SDL forum where I am a member.  I'll try that first.  Thanks
>> for the info.
>
> I'd say SDL is way over the top for this.

I'd say he's already using SDL, so it makes sense to point him in the 
direction of SDL help.

<snip>

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#59125

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-03-28 05:53 -0700
Message-ID<fc015833-c906-498e-8553-3d0a741a16c0@googlegroups.com>
In reply to#59119
On Saturday, March 28, 2015 at 11:07:55 AM UTC, bilsch wrote:
> This question is not related to a similar question I posted previously 
> regarding command line arguments.  That problem is solved - this is 
> different.   I made a program that draws Lissajous patterns (periodic 
> graphs) using sine functions and exponential functions.  There are many 
> parameters that affect the display of these graphs. There is 'front end' 
> code that allows user to set these parameters using scanf.  This front 
> end should query the user any time the program is started - indeed it 
> does when the program is started from the command line.  I have an icon 
> on my Ubuntu desktop that starts the program when you double click the 
> icon - however when you do it that way none of the user querys are 
> executed.  The program simply runs using the values initialized when the 
> variables were declared. This behavior is a mystery to me. How does it 
> skip over the front end code? I have another simpler program structured 
> the same way and it has the same behavior when started by double clicking 
> the icon.
> 
A C program has streams which can be opened with fopen() and extensions
like open(). Sometime these are files on disk, other time they are 
pipes to other programs. 
It's also got three special streams, stdout, stdin, and stderr. 
C was designed for a command-line environment, and those streams  
only really make sense when a program is being run interactively
at a command prompt.

However modern programs are often graphical. They open windows
and interact with user via drawing pixels, mouse clicks, and some
sort of system for attaching the keyboard to an active input
window, such as the one I'm currently typing at. But because stdin,
stdout and stderr are declared in stdio.h, which is also used for
file access, the streams still usually exist.

However they might not do anything. Or they might be attached to
the command prompt is the program was started via a command, 
and to thin air if it was started via an icon.

However there's a freopen() command that you can use to redirect
stdin stdout and stderr. So commonly when programs are being debugged,
and the developer wants to scatter printf() and scanfs(), the 
streams are attached to an interactive prompt, which often pops
up in its own window.
If you do a web search on your operating system and "redirecting 
stdout / stdin" you'll find out how to do this.

[toc] | [prev] | [next] | [standalone]


#59143

Frombilsch <king621@comcast.net>
Date2015-03-28 15:39 +0000
Message-ID<mf6hvl$hek$1@dont-email.me>
In reply to#59125
> 
> However there's a freopen() command that you can use to redirect stdin
> stdout and stderr. So commonly when programs are being debugged, and the
> developer wants to scatter printf() and scanfs(), the streams are
> attached to an interactive prompt, which often pops up in its own
> window.
> If you do a web search on your operating system and "redirecting stdout
> / stdin" you'll find out how to do this.

I searched as you suggested and read a lot I don't understand - and 
nothing specific to anything I do understand.  Apparently I need to use 
this freopen() command in my program and somehow get an interactive 
window to pop up that will show the text output by the printf() commands 
and accept input to the scanf() commands which are in my program. The 
program needs to get Ubuntu to provide this interactive window or does 
the code have to create the interactive window? 

[toc] | [prev] | [next] | [standalone]


#59151

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-03-28 09:24 -0700
Message-ID<d8a6d70c-4579-4cc8-afb5-4fb7bb8293cd@googlegroups.com>
In reply to#59143
On Saturday, March 28, 2015 at 3:40:33 PM UTC, bilsch wrote:
> > 
> > However there's a freopen() command that you can use to redirect stdin
> > stdout and stderr. So commonly when programs are being debugged, and the
> > developer wants to scatter printf() and scanfs(), the streams are
> > attached to an interactive prompt, which often pops up in its own
> > window.
> > If you do a web search on your operating system and "redirecting stdout
> > / stdin" you'll find out how to do this.
> 
> I searched as you suggested and read a lot I don't understand - and 
> nothing specific to anything I do understand.  Apparently I need to use 
> this freopen() command in my program and somehow get an interactive 
> window to pop up that will show the text output by the printf() commands 
> and accept input to the scanf() commands which are in my program. The 
> program needs to get Ubuntu to provide this interactive window or does 
> the code have to create the interactive window?

Try this link
(I haven't been through the process myself, so I can't promise the
method works. Will try when I'm at my Linux machine.)

http://www.linuxmisc.com/9-unix-programmer/db8ad3ce8738d394.htm

[toc] | [prev] | [next] | [standalone]


#59153

Frombilsch <king621@comcast.net>
Date2015-03-28 17:05 +0000
Message-ID<mf6n11$hek$2@dont-email.me>
In reply to#59151
> 
> Try this link (I haven't been through the process myself, so I can't
> promise the method works. Will try when I'm at my Linux machine.)
> 
> http://www.linuxmisc.com/9-unix-programmer/db8ad3ce8738d394.htm

I got it to compile and run.  It says:
 parent process is 4876
 parent process is 4877

I don't know what to do with that. 

[toc] | [prev] | [next] | [standalone]


#59154

Frombilsch <king621@comcast.net>
Date2015-03-28 17:08 +0000
Message-ID<mf6n5r$hek$3@dont-email.me>
In reply to#59151
are those numbers needed for me to redirect stdin and stdout ?

[toc] | [prev] | [next] | [standalone]


#59183

FromKeith Thompson <kst-u@mib.org>
Date2015-03-28 17:34 -0700
Message-ID<877fu0myj3.fsf@kst-u.example.com>
In reply to#59143
bilsch <king621@comcast.net> writes:
>> However there's a freopen() command that you can use to redirect stdin
>> stdout and stderr. So commonly when programs are being debugged, and the
>> developer wants to scatter printf() and scanfs(), the streams are
>> attached to an interactive prompt, which often pops up in its own
>> window.
>> If you do a web search on your operating system and "redirecting stdout
>> / stdin" you'll find out how to do this.
>
> I searched as you suggested and read a lot I don't understand - and 
> nothing specific to anything I do understand.  Apparently I need to use 
> this freopen() command in my program and somehow get an interactive 
> window to pop up that will show the text output by the printf() commands 
> and accept input to the scanf() commands which are in my program. The 
> program needs to get Ubuntu to provide this interactive window or does 
> the code have to create the interactive window? 

If you're on Ubuntu, just run the program from a shell prompt.  Its
stdin, stdout, and stderr will be inherited from the shell: stdin will
read from the keyboard, and stdout and stderr will write to the terminal
(emulator).

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#59128

FromLőrinczy Zsigmond <nospam@for.me>
Date2015-03-28 14:35 +0100
Message-ID<mf6am1$nsb$1@speranza.aioe.org>
In reply to#59119
> I have an icon
> on my Ubuntu desktop that starts the program when you double click the
> icon - however when you do it that way none of the user querys are
> executed.

Actually, they are executed and all of them returns 0 (or less),
meaning: couldn't read anything from standard input:
in this context standard input is redirected to(from) /dev/null.

You can use command line arguments,
or create a GUI-interface to prompt the parameters.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web