🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #397

Default input value in C

#397
From: mbt4w
Date: Sun, 10 Jan 1999 00:00
31 lines
1567 bytes
Hi,

I would like to allow defaults to user input in C. 
I'm using Borland C++ 4.52 on Win98. I'm trying to learn 
standard C programming or has close as possible even though 
I'm using a C++ package.   It seems the input commands I've 
tried so far will not allow an 'empty' entry. 

What I would like to happen is :
� Prompt the user for an input while displaying a default entry
� If the user presses only the enter key use the default entry
� If another value was entered, used it.

Below is a basic program that does this. 
How do I do it in C?

text$ = "This is default text"
amount = 50
PRINT
PRINT "Enter something if you like! <"; text$; "> ";
INPUT x$
IF x$ <> "" THEN text$ = x$
PRINT "Enter a value. <"; amount; "> ";
INPUT x
IF x <> 0 THEN amount = x
PRINT
PRINT "The value of text$ now = "; text$
PRINT "The amount ="; amount


Thanks
Technical Details
Message-ID: <36990041.3BADD052@overthere.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f8d38,6ac36e1493d03328,start
X-Google-Attributes: gidf8d38,public
X-Google-Thread: 114592,6ac36e1493d03328,start
X-Google-Attributes: gid114592,public
X-Google-Thread: 161995,6ac36e1493d03328,start
X-Google-Attributes: gid161995,public
From: mbt4w <DontlikeSpam@overthere.com>
Subject: Default input value in C
Date: 1999/01/10
Message-ID: <36990041.3BADD052@overthere.com>
X-Deja-AN: 430970025
Content-Transfer-Encoding: 8bit
Organization: Verio Mid-Atlantic
Content-Type: text/plain; charset=iso-8859-1
Mime-Version: 1.0
Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.language,comp.os.msdos.language