473,498 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Letter question

11 New Member
How to make a program that says enter calculation. If a person enters non-numeric letter to say "That is an invalid operation"
Sep 14 '09 #1
6 1695
JosAH
11,448 Recognized Expert MVP
@IgorZ
Check the isdigit() macro from the ctype.h file. For convenience first read in the entire line and check all the chars in it. Note that this gives you a necessary check that still isn't sufficient.

kind regards,

Jos
Sep 14 '09 #2
Tassos Souris
152 New Member
Exactly.. if you must support floating point numbers going through the characters and manually checking with isdigit() is not so *promising*..

See at the function strtod() strtol() in header <stdlib.h>
To read the line use fgets() and not gets() or scanf().
Sep 14 '09 #3
JosAH
11,448 Recognized Expert MVP
@Tassos Souris
Lexical analysis is a burden, even if you only want to recognize ints; what if the user types eighty nines in a row? Theoretically it's an int. It won't fit in four or even eight bytes though ...

kind regards,

Jos
Sep 14 '09 #4
Tassos Souris
152 New Member
I agree.. personally i use doubles and strtod() when i need to.. strtod()
notifies when an overflow or underflow occurs :)
Sep 14 '09 #5
IgorZ
11 New Member
How about when a person enters a letter instantly to delete it? Is that possible?
Sep 15 '09 #6
Savage
1,764 Recognized Expert Top Contributor
@IgorZ
ungetc() may help, check this out.

You will ofcourse need to modify the sample a bit ^^
Sep 15 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

12
6000
by: Alan J. Flavell | last post by:
OK, today's email brought a comment from a reader, pointing out something that I'd long since noticed myself but hadn't done anything about it. On my pages, I've got a first-letter style on...
4
3022
by: Ian | last post by:
I am using Access 97 SR1, when I move my database to another PC some or all of the reports change from English A4 to American Letter. I am sure this has been addressed many times but I cant find...
2
1599
by: JLeonard | last post by:
I would like to save my Access form letters as a txt file who's file name matches the value in a 'last name' field. One file for each record. Any ideas for how I might do this? Thanks in...
4
12499
by: George Thompson | last post by:
How can I retrieve the first letter of data in a field within access? (using access 2k?) is this a VB thing or is there an obvious solution?
0
1628
by: Gidi | last post by:
Hi, i'm writing this question again, since i didn't get an answer in the reply i wrote, i hope it's ok. My user default language is hebrew and in some specific TextBoxs i want that the...
2
3353
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
9
2216
by: Ulterior | last post by:
Hi, everyone, I have a simple problem, which bothers me for some while. I will try to explain it - There is some string, whith different letters in it. Is it possible to analyse this string...
3
1762
by: =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki | last post by:
How do it's by next of boost.spirit library it are not discrimitation a letter size that a small letters and big letters it are not discrimitation? I'm know how write s small parser by next of...
2
1973
by: sehodge | last post by:
<STYLE type="text/css"> P { font-size: 10pt; color:#000;} P:first-letter { font-size: 150%; color:red; font-weight: bold; float: left } </STYLE> Later, I want the first...
2
1637
dlite922
by: dlite922 | last post by:
Before i spend hours coding this thing, i want to see if there's already a solution or one of you has built something close to it. Please suggest anything that may relate to any of the following ...
0
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7208
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.